5 ms·
If you're going to use string literal, then echo '{"name": "JP", "object": {"fruit": "Orange", "point": {"x": 10, "y": 20}, "number": 17}, "sunday": false}'
by mmgutz 5y ago
If you're going to use string literal, then
echo '{"name": "JP", "object": {"fruit": "Orange", "point": {"x": 10, "y": 20}, "number": 17}, "sunday": false}'
is fine as a script
- anamexis 5y agoAll fun and games until you need quoting. Quoting in shell scripts is already hellish enough, but layering JSON quoting on top of that is a road to madness.
- mkdirp 5y agoCombining here-string with `jq` (if you need variables), is plenty good enough. You'd need a single jq invocation.
- anamexis 5y agoYes, `jq` would work fine, but so would `jo`. The point is, if there is anything more than the simplest dynamic values, constructing valid JSON just with POSIX shell is a huge pain.
- deleted 5y ago[deleted]