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

[Request] Strip excessive whitespace when exporting JSON with --output-format={bash|cmd} #71

Closed
Reino17 opened this issue Jun 20, 2021 · 3 comments

Comments

@Reino17
Copy link

Reino17 commented Jun 20, 2021

Linux:

$ xidel -s '{"a":1,"b":"x y z","c":null}' -e '$json' --output-format=bash
result='{"a": 1, "b": "x y z", "c": null}'

Windows:

xidel -s "{'a':1,'b':'x y z','c':null}" -e "$json" --output-format=cmd
SET result={^"a^": 1^, ^"b^": ^"x y z^"^, ^"c^": null}

It's almost as if the JSON input is serialized with serialize-json() as opposed to serialize():

xidel -s '{"a":1,"b":"x y z","c":null}' -e 'serialize-json($json)'
{"a": 1, "b": "x y z", "c": null}

xidel -s '{"a":1,"b":"x y z","c":null}' -e 'serialize($json,{"method":"json"})'
{"a":1,"b":"x y z","c":null}

(isn't serialize-json() unnecessary/superfluous now?)

Probably less a concern on Linux, but Windows cmd its commandline buffer is only 8KB. So cmd variables can only hold a max of 8192 characters.
With that in mind can you please strip excessive whitespace, like serialize() does, when exporting JSON with --output-format={bash|cmd}, Benito?

@Reino17
Copy link
Author

Reino17 commented Jul 21, 2021

One month later. Can you at least share your opinion on the matter?

@benibela
Copy link
Owner

It's almost as if the JSON input is serialized with serialize-json() as opposed to serialize():

yes

One month later.

Already? It feels like yesterday

Can you at least share your opinion on the matter?

it is not so easy to change

@Reino17
Copy link
Author

Reino17 commented Aug 23, 2021

Very nice. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants