News for hackers. Stuff that matters.
Re:The Order of the JSON by crazygringo on Thursday August 15, 2019 @11:23PM (#20711914)
+1 for all reasons above for ordered JSON, highly convenient in practice.

And if it doesn't impact performance significantly, these are all pretty good reasons for JSON outputters to default to sorting objects deterministically by keys, or at least to provide a flag to do so. (Even if there's no canonical sort order between JSON libraries, all that matters is it's deterministic for each library.)

BUT... I can't imagine any scenario where you'd want to validate that JSON content was ordered on the input, which is what was enabled in this article. Why does IBM even have that as an option?!

Be strict in what you emit and liberal in what you accept, and all that...

Re:The Order of the JSON by hyperpallium on Friday August 16, 2019 @12:00AM (#20712070)
I guess because OrderedJSONObject is ordered, not sorted. Like java's LinkedHashSet, it maintains the order keys are added.

If you're going to rely on a specific order for comparisons, it makes sense to alert the user to any JSON in a different order (instead of silently, liberally accepting it), or you'll get false negatives elsewhere. Easier to check for a sorted order, but also possible to define a specific order. IDK what IBM did here.

funfact: jq used to sort keys; now it retains ordering.

Re:The Order of the JSON by diroussel on Friday August 16, 2019 @04:27AM (#20713196)
Indeed, and remember this JSON message is going to a mainframe. Mainframes don't have much memory and typically process record-by-record, or event-by-event. So the implemenations probably streams the JSON in and constructs COPYBOOK from the payload before continuing to invoke the cobol.

So the rework time might be to write a general purpose re-order layer that can re-order any imcoming message.

Re:The Order of the JSON by tantalor on Friday August 16, 2019 @08:38AM (#20714538)
> any scenario where you'd want to validate...

Because it's a precondition for something else down the line (a dependency)