-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
Suppose I'd like to parse a JSON array and output its members:
echo '[4,"foo", "[]",[],{"hi": "world"}]' | jq ".[]"There are a few conventions for newline-delimited JSON values, but this requires having a JSON parser. Fortunately, the NUL delimiter convention is pretty wide-spread and makes it easy for another process to split the values.
Unfortunately, jq only has the --raw-output0, which removes quotes from strings.
echo '[4,"foo", "[]",[],{"hi": "world"}]' | jq ".[]" --raw-output0As a result:
- Some entries of the output are no longer parseable as JSON (e.g.
"foo"→foo) - Certain entries are serialized in the same way, making it impossible to recover the original data (e.g.
"[]"and[]both serialize to[]).
This could be solved with a flag like --output0 that applies the NUL delimiter without raw formatting.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels