json4shell icon indicating copy to clipboard operation
json4shell copied to clipboard

Wrap json-iterate output like array

Open noway opened this issue 11 years ago • 3 comments
trafficstars

Current json-iterate output:

echo '[1,2,3,4]'| ./json-iterate -j echo {}
{"returncode": 0, "stderr": "", "stdout": "1\n"}
{"returncode": 0, "stderr": "", "stdout": "2\n"}
{"returncode": 0, "stderr": "", "stdout": "3\n"}
{"returncode": 0, "stderr": "", "stdout": "4\n"}

Proposal:

echo '[1,2,3,4]'| ./json-iterate -j echo {}
[{"returncode": 0, "stderr": "", "stdout": "1\n"},
{"returncode": 0, "stderr": "", "stdout": "2\n"},
{"returncode": 0, "stderr": "", "stdout": "3\n"},
{"returncode": 0, "stderr": "", "stdout": "4\n"}]

noway avatar Jun 18 '14 00:06 noway

I can do this, but it more about other idea - to accept such 'stacked json' as valid input. The problem is that if application terminates unexpectedly, in case of array, it will leave invalid json. Moreover, there is a lot of problems with normal 'grep-like' operations.

I really like to keep compatibility with current type of shell line-based processing.

I think whole thing is about input, not output - we should be able to take as valid input those things:

[ "1", "2", "3", ]

[ "1", "2",

"2", "3" ]

"1" "2" "3"

I see how tricky it's gonna be, but it's absolutely necessary to allow relaxed input - else it's gonna be very unfriendly to user, who gonna be forced to 'hacks' around pipe just to satisfy inputs.

amarao avatar Jun 18 '14 18:06 amarao

Hm, your arguments convinced me. Okay then.

Leaving this issue open for future discussion, anyway.

noway avatar Jun 18 '14 19:06 noway

Yep, I'll change output to full json (just need to find way how to generate output steady). I think, it's gonna be clear after I repeat my experiments with JSONStreams

amarao avatar Jun 18 '14 20:06 amarao