4 ms·
I use JSON, because it's simple yet powerful. Command line JSON tools seem to have a very convoluted syntax and that kinda defeats the whole purpose.
by yAnonymous 9y ago
I use JSON, because it's simple yet powerful. Command line JSON tools seem to have a very convoluted syntax and that kinda defeats the whole purpose.
- vidarh 9y agoI don't think there's a whole lot more we can achieve beyond what you see there... I mean, I guess you could dynamically assign global variables based on the keys, and enforce treating them as strings, so you could reduce it to jr 'puts{$number+": "+$title}' E.g by changing the "each" in my example with: def each █ $J.each do |i| $I = i; i.keys.each {|k| eval("$#{k} = $I[k].to_s")} block.call(i) end end Though this is error prone - e.g. if the key collides with any pre-defined Ruby globals like $stdin... Would probably be worth using a prefix etc.. This is the downside to using a general purpose language for stuff like this instead of a specialised tool like jq which can ignore other syntax concerns..