6 ms·
JSONx is an IBM standard format to represent JSON as XML
- namecast 12y agoFrom the department-of-redundancy-department.... The output syntax is even more glorious than you'd think: <?xml version="1.0" encoding="UTF-8"?> <json:object xsi:schemaLocation="http://www.datapower.com/schemas/json http://www.datapower.com/schemas/json jsonx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" http://www.w3.org/2001/XMLSchema-instance" xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx"> http://www.ibm.com/xmlns/prod/2009/jsonx"> <json:string name="name">John Smith</json:string> <json:object name="address"> <json:string name="streetAddress">21 2nd Street</json:string> <json:string name="city">New York</json:string> <json:string name="state">NY</json:string> <json:number name="postalCode">10021</json:number> </json:object> <json:array name="phoneNumbers"> <json:string>212 555-1111</json:string> <json:string>212 555-2222</json:string> </json:array> <json:null name="additionalInfo" /> <json:boolean name="remote">false</json:boolean> <json:number name="height">62.4</json:number> <json:string name="ficoScore"> > 640</json:string> </json:object> ...and no, I'm not joking, and don't call me Shirley.
- duaneb 12y agoI don't think JSONx is built for readability, so that actually seems like a very reasonable way to convert to XML.
- laydros 12y agoyeah, the point isn't so much to make it readable, but to allow you to write JSON (as a python dev I love the interoperability with JSON) and then use the capabilities of the DataPower to do stuff with it. I expect many people were doing this by hand since JSON has replaced XML in a lot of peoples minds, and IBM has created a way to standardize it to make it easier to work with other teams.
- masklinn 12y agoThat doesn't make this mess any saner, if the point was to apply XML tools to JSON, why not convert to an existing XML dialect with equivalent expressive power, e.g. XMLRPC's serialisation format (which provides a strict superset of JSON capabilities (if you include the nil extension))?
- duaneb 12y agoThe obvious problem being that you might not have control over the source of the data. JSONx means you can apply xml tools to json sources, period.
- masklinn 12y agoI'm not sure what you're trying to say. The source of the data is irrelevant, XMLRPC w/ nil (and other pre-existing formats I'm sure) are strict supersets of JSON, any JSON document can be converted back and forth between XMLRPC and JSON without data loss. So XMLRPC (or something else with similar capabilities) would give you exactly the same ability to apply XML tools to "JSON sources".
- andrewstuart2 12y agoI've never understood the reasoning behind using a textual serialization format that's not human readable. If you don't want it to be readable, make the darn thing binary and go for efficiency.
- xienze 12y agoIt 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.
- sp332 12y agoBut what if the original JSON had a string that looks like XML? Does {"endTag": "</json:string>"} become <json:string> </json:string> </json:string> ?
- masklinn 12y agoOf course not, it's either embedded in a CDATA section or the characters are escaped to the relevant entities: http://www.w3.org/TR/xml/#syntax http://www.w3.org/TR/xml/#syntax > The ampersand character (&) and the left angle bracket (<) must not appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the strings " & " and " < " respectively. The right angle bracket (>) may be represented using the string " > ", and must, for compatibility, be escaped using either " > " or a character reference when it appears in the string " ]]> " in content, when that string is not marking the end of a CDATA section.
- bitwize 12y agoThey'd probably escape out the angle brackets with entities. Sorry, Bobby Tables.
- sp332 12y agoProbably, well hopefully, sure. But I want to know whether they did, and whether the technique is fragile.
- figglesonrails 12y agoI don't really understand why you are being down voted for a technical question. It seems like answering it without giving a downvote as a snarky "ISN'T IT OBVIOUS?" would be sufficient.
- deleted 12y ago[deleted]
- pbreit 12y agoNot sure what you mean, the result looks fairly restrained to me.
- donpdonp 12y agoThe xml namespace descriptors are bulky. The rest looks efficient, for xml, and almost readable with some indentation. <?xml version="1.0" encoding="UTF-8"?> <json:object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx" xsi:schemaLocation="http://www.datapower.com/schemas/json jsonx.xsd"> <json:string name="name">John Smith</json:string> <json:object name="address"> <json:string name="streetAddress">21 2nd Street</json:string> <json:string name="city">New York</json:string> <json:string name="state">NY</json:string> <json:number name="postalCode">10021</json:number> </json:object> <json:array name="phoneNumbers"> <json:string>212 555-1111</json:string> <json:string>212 555-2222</json:string> </json:array> <json:null name="additionalInfo"/> <json:boolean name="remote">false</json:boolean> <json:number name="height">62.4</json:number> <json:string name="ficoScore"> > 640</json:string> </json:object> translated (by hand) into JSON gives { "name": "John Smith", "address": { "streetAddress": "21 2nd Street", "city": "New York", "state": "NY", "postalCode": 10021 }, "phoneNumbers": ["212 555-1111", "212 555-2222"], "additionalInfo": null, "remote": false, "height": 62.4, "ficoScore": " > 640" }
- tiles 12y agoI'm surprised it doesn't use any of RDF's ordering attributes for arrays and objects.
- rasz_pl 12y agowell, IBM does sell storage solutions.
- kra34 12y agobut where can you buy their complicator gloves?
- CamperBob2 12y agoYou get a free pair with every turboencabulator purchase.
- ribs 12y agoWith panadermic semi-boloid slots? (Fully boloid slots require a macroflanging compensator, and who's got the money)
- linker3000 12y agoIs it a per-slot licence model?
- HCIdivision17 12y agoI always liked its tungsten cowhide casing [0], but the newer retroencabulator's removal of the expensive to dispose tetraethyliodohexamine greatly cuts down on the recurring maintenance costs. [0] http://www.floobydust.com/turbo-encabulator/ge_turbo-encabulator.pdf http://www.floobydust.com/turbo-encabulator/ge_turbo-encabul...
- laydros 12y agoI worked on the Datapower team soon after IBM acquired the product. Its a very cool device. But I read the headline and threw up in my mouth a little.
- easytiger 12y agoApril Fools?
- powdahound 12y agoReminds me of the "JSON Encodings for XMPP" specification. :) http://xmpp.org/extensions/xep-0295.html http://xmpp.org/extensions/xep-0295.html
- kttmrt 12y agoWhy?
- Scuds 12y agoENTERPRISE READY!
- danbruc 12y agoBecause there are already tool chains to handle XML with features not (widely) available for JSON, for example validation (XSD) and transformation (XSLT).
- jabits 12y agoThis is so true. Xsd is so useful.
- mrweasel 12y agoSame reason as SOAP/WSDL: there's good money in consulting so it would be stupid to do something that to simple, people might be able to solve their own problems. Honestly I get that there an advantage in respect to tooling and this might ease integration into existing system, but I can't help feel that this is introducing an extra level of complexity that you would only find acceptable if you at IBM customer level scale. The ability to introduce at least some type safety seems nice though.
- dragonwriter 12y agoTo use existing XML 1.0 tools on data that comes in as JSON. It may be somewhat problematic that it doesn't actually support all JSON, because the characters that are permitted (even with escapes) in XML 1.0 text do not include all characters that can appear in JSON values, so if you use it on legal JSON that isn't constrained to be XML 1.0 compatible, it will do something wrong (the docs aren't clear on whether it will fail or just drop the offending characters), so the only place that it seems safe to use is in a constrained internal environment where you control "JSON" to mean "JSON using XML-1.0-safe characters".
- 12y ago
- edwingustafson 12y agoMost likely they developed this format to store JSON in DB2 or to manipulate JSON with existing XML-based tools.
- the_mitsuhiko 12y agoThat's exactly what this is: http://www.ibm.com/developerworks/library/x-db2JSONpt1/ http://www.ibm.com/developerworks/library/x-db2JSONpt1/
- dapatil 12y agoWhy?
- Norm-- 12y agoAnd now the next trick I will perform is turning XML into JSON
- OhhHeyTyler 12y agohttps://gist.github.com/DavidJFelix/e5f16d4d1f8760bc3b39 https://gist.github.com/DavidJFelix/e5f16d4d1f8760bc3b39 buddy of mine made JSHOL on a whim which creates html from json
- linker3000 12y agoHaving just written a pair of Nagios plugins in bash and batch that include json parsing routines, all I can say is "meh"... and my brain still hurts!
- Norm-- 12y agoSounds like your buddy just inadvertently created the Turducken of data-interchange formats http://en.wikipedia.org/wiki/Turducken http://en.wikipedia.org/wiki/Turducken
- dyoo1979 12y agoWait, this can't be right for purely technical reasons: what would this to do a string containing vertical tab characters? Such strings are illegal in XML. I see nothing in the "JSONx Conversion Rules" that addresses the problem that the strings representable in XML are a smaller set than those in JSON. [edit] Yup, confirmed. The documentation says: "The \b (backspace) and the \f (form feed) characters are not supported in XML and, subsequently, are not supported in JSONx." So not only does this JSON->XML thing seem obtuse, but it's partial. I wrote a rant about this point a few days ago. Seems more well timed than I had hoped. https://plus.google.com/117593568781545916065/posts/ViNzo5JjbRf https://plus.google.com/117593568781545916065/posts/ViNzo5Jj...
- dragonwriter 12y ago> So not only does this JSON->XML thing seem obtuse, but it's partial. If it wasn't partial, it would be useful -- allowing existing XML tools to easily consume and/or produce JSON tools by applying a JSON -> XML on input and/or XML -> JSON on output would be valuable. But when the conversion is restricted to an XML-1.0-compatible-subset of JSON, the value drops considerably.
- JonnieCache 12y agoOh good, you can convert it back to JSON with an XSLT.
- drivingmenuts 12y agoI just had a flashback. XSLT really is the seventh circle of Hell.
- jmsduran 12y agoThis does not surprise me one bit, I'm pretty sure IBM holds a patent for this somehow.
- thrush 12y agoThis is SO SO important. I've had to convert JSON to XML and vice versa so many times in order to transfer data to and from legacy code components. No, I don't think an ideal world involves any sort of communication where one side speaks JSON and the other speaks XML, but the current world very much needs a standardization like this.
- dragonwriter 12y agoInsofar as the world needs a JSON->XML conversion standard, it needs one that handles all legal JSON, which this doesn't (it could if it used the same approach to target XML 1.1 instead of XML 1.0, or it could if it used a slightly more complex representation of JSON strings in the XML 1.0, but instead it chose to be a conversion for a restricted XML-1.0-friendly subset of JSON.)
- DonHopkins 12y agoDoes it support EBCDICTF8 (Extended Binary Coded Decimal Interchange Code Transformation Format Eight) for encoding Unicode as 8 bit EBCDIC?
- peterwwillis 12y agoWhat, is this supposed to be funny? You try converting completely different formats into one another without a standard, and see the kinds of fucked up bug reports you get.
- marcofiset 12y agoWait.... what ?
- lovelearning 12y agoThey missed a golden chance to name it "Enterprise JSON".
- dreamweapon 12y ago"The horror... the horror!"
- valarauca1 12y agoWebSphere! Experience everything wrong with Enterprise Software Development for the simple price of $100,000 per seat, per core, per year :D
- angersock 12y agoWell, they did get a license from Crockford to use JSON for evil, so mission accomplished I guess?
- unclebunkers 12y agoWhat is this for?
- kevinSuttle 12y agoHow recent is the introduction of this format interchange?
- pedrospdc 12y agoThis should not be used anywhere, never.
- neilellis 12y agoThey killed a 1000 unicorns to make this you know. I can hear the screams in my sleep.