Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty print partial JSON #84

Open
RopoMen opened this issue Jun 15, 2017 · 0 comments
Open

Pretty print partial JSON #84

RopoMen opened this issue Jun 15, 2017 · 0 comments

Comments

@RopoMen
Copy link

RopoMen commented Jun 15, 2017

Hi,

I was wondering would it be possible to pretty print "invalid/broken" JSON? My use case is that I have partial json file which is valid from the begining, but it ends at some point.

I think it would be possible to pretty print that json string as long as the file continues and stop then.
Now if JSON ends unexpectedly it does not pretty print valid JSON before that.

For example I have 200 Mb json file from which I extracted part by

dd if=large_200mb.json ibs=1 skip=0 count=100000 > small.txt

Now I would like to pretty print that small.txt as far as the valid json continues.

Example 1:

{"a": 123,"b":4,"c":"cat","d":{"y":2,"x":45}}

If I select "cat","d":{"y":2,"x":45}}" from that example and pretty print that, I would like it to pretty print it like

cat","d":{
  "y":2,
  "x":45
}}

If I select ""y":2,"x":45}}" It would do nothing.

Example 2:

{"a": 123,"b":4,"c":"cat","d":{"y":2,

If I select that completely and pretty print it, I would like it to give result like

{
  "a": 123,
  "b":4,
  "c":"cat",
  "d":{
    "y":2,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants