4 ms·
It would look a lot more reasonable if they had set the root namespace instead of leaving it separate and requiring every element to be prefixed.
by xienze 12y ago
It would look a lot more reasonable if they had set the root namespace instead of leaving it separate and requiring every element to be prefixed.
- namecast 12y agoYep. The rest of it is, well, xml, and it's not going to be as clean looking as json , but why do I need to see the word json at the start and stop of every element? It could at least be abbreviated to just 'j'? On the plus side I bet the output gzip's up rather nicely in transit assuming you're HTTP GET'ting this data....
- wereHamster 12y agoReplace `xmlns:json="http://...` http://...` with `xmlns:j="http://...` http://...`.
- moron4hire 12y agoActually, just remove the colon and the prefix entirely. It becomes surprisingly readable: <object xsi:schemaLocation="http://www.datapower.com/schemas/json jsonx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.ibm.com/xmlns/prod/2009/jsonx"> <string name="name">John Smith</string> <object name="address"> <string name="streetAddress">21 2nd Street</string> <string name="city">New York</string> <string name="state">NY</string> <number name="postalCode">10021</number> </object> <array name="phoneNumbers"> <string>212 555-1111</string> <string>212 555-2222</string> </array> <null name="additionalInfo" /> <boolean name="remote">false</boolean> <number name="height">62.4</number> <string name="ficoScore"> > 640</string> </object>
- masklinn 12y ago> On the plus side I bet the output gzip's up rather nicely in transit assuming you're HTTP GET'ting this data.... The XML is 901 bytes, gzip yields 401 (44.5%) Of course the original JSON is 303 bytes and JSON is already pretty compressible, to 215 bytes (71%) in this case.
- xienze 12y ago> but why do I need to see the word json at the start and stop of every element? Because of what I just mentioned. If they had set the root namespace directly you wouldn't have to declare the namespace prefix on every element.
- colanderman 12y agoI don't know why you were downvoted. Setting the root namespace provides exactly the effect of dropping "json:" from everything.