4 ms·
Pretty printing JSON is mostly for developer consumption, I'm not sure how the pretty printed JSON would end up being fed automatically to another system? (I h
by Macha 6y ago
Pretty printing JSON is mostly for developer consumption, I'm not sure how the pretty printed JSON would end up being fed automatically to another system?
(I have actually encountered a order-dependent JSON-subset parser before, but to my mind, that code is broken)
- peterohler 6y agoPretty JSON is still just JSON. It should work with any JSON parser. Of course if it is being fed from one system to another there is no need to make the JSON anything other than compact one line JSON. Pretty is for human consumption.
- jandrese 6y agoSome parsers will reject JSON that has whitespace around the elements. Pretty JSON is really only for human consumption.
- wayneftw 6y agoOutside of pretty printing - MySQL breaks your app if you depend on key order in an object because it alphabetically sorts object keys when you store it in a JSON column. JavaScript itself will also sort object keys if they are numeric, so `{a: "a", c: "c", b: "b", "1": 1};` will be transformed to `{1: 1, a: "a", c: "c", b: "b"}`.