News for hackers. Stuff that matters.
Re:JSONx is an IBM standard format to represent JSON as XML by namecast on Tuesday September 23, 2014 @01:31PM (#8356641)
From 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 jsonx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:json="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.

Re:JSONx is an IBM standard format to represent JSON as XML by donpdonp on Tuesday September 23, 2014 @01:59PM (#8356896)
The 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"> &gt; 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"
  }
Re:JSONx is an IBM standard format to represent JSON as XML by duaneb on Tuesday September 23, 2014 @01:33PM (#8356666)
I don't think JSONx is built for readability, so that actually seems like a very reasonable way to convert to XML.
Re:JSONx is an IBM standard format to represent JSON as XML by laydros on Tuesday September 23, 2014 @01:36PM (#8356690)
yeah, 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.

Re:JSONx is an IBM standard format to represent JSON as XML by masklinn on Tuesday September 23, 2014 @02:16PM (#8357051)
That 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))?
Re:JSONx is an IBM standard format to represent JSON as XML by duaneb on Tuesday September 23, 2014 @03:11PM (#8357485)
The 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.
Re:JSONx is an IBM standard format to represent JSON as XML by masklinn on Wednesday September 24, 2014 @04:01AM (#8360343)
I'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".
Re:JSONx is an IBM standard format to represent JSON as XML by andrewstuart2 on Tuesday September 23, 2014 @01:52PM (#8356824)
I'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.

Re:JSONx is an IBM standard format to represent JSON as XML by pbreit on Tuesday September 23, 2014 @01:54PM (#8356848)
There's a difference between prioritizing readability and simply being readable.
Re:JSONx is an IBM standard format to represent JSON as XML by mackwic on Tuesday September 23, 2014 @05:35PM (#8358436)
Please explain the trade off, I can't see myself debugging an unindented XML file without an appropriate reader. Exactly like a binary file.
Re:JSONx is an IBM standard format to represent JSON as XML by xienze on Tuesday September 23, 2014 @01:36PM (#8356693)
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.
Re:JSONx is an IBM standard format to represent JSON as XML by namecast on Tuesday September 23, 2014 @01:40PM (#8356716)
Yep. 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....

Re:JSONx is an IBM standard format to represent JSON as XML by wereHamster on Tuesday September 23, 2014 @01:45PM (#8356764)
Replace `xmlns:json="http://...` with `xmlns:j="http://...`.
Re:JSONx is an IBM standard format to represent JSON as XML by moron4hire on Tuesday September 23, 2014 @01:57PM (#8356879)
Actually, 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>
Re:JSONx is an IBM standard format to represent JSON as XML by masklinn on Tuesday September 23, 2014 @01:45PM (#8356769)
> 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.

Re:JSONx is an IBM standard format to represent JSON as XML by xienze on Tuesday September 23, 2014 @01:51PM (#8356811)
> 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.

Re:JSONx is an IBM standard format to represent JSON as XML by colanderman on Tuesday September 23, 2014 @03:38PM (#8357661)
I don't know why you were downvoted. Setting the root namespace provides exactly the effect of dropping "json:" from everything.
Re:JSONx is an IBM standard format to represent JSON as XML by pbreit on Tuesday September 23, 2014 @01:52PM (#8356828)
Not sure what you mean, the result looks fairly restrained to me.
Re:JSONx is an IBM standard format to represent JSON as XML by tiles on Tuesday September 23, 2014 @02:46PM (#8357295)
I'm surprised it doesn't use any of RDF's ordering attributes for arrays and objects.
Re:JSONx is an IBM standard format to represent JSON as XML by sp332 on Tuesday September 23, 2014 @01:46PM (#8356770)
But what if the original JSON had a string that looks like XML? Does {"endTag": "</json:string>"} become <json:string> </json:string> </json:string> ?
Re:JSONx is an IBM standard format to represent JSON as XML by masklinn on Tuesday September 23, 2014 @01:48PM (#8356792)
Of 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

> 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 " &amp; " and " &lt; " respectively. The right angle bracket (>) may be represented using the string " &gt; ", and must, for compatibility, be escaped using either " &gt; " or a character reference when it appears in the string " ]]> " in content, when that string is not marking the end of a CDATA section.

Re:JSONx is an IBM standard format to represent JSON as XML by bitwize on Tuesday September 23, 2014 @01:53PM (#8356833)
They'd probably escape out the angle brackets with entities. Sorry, Bobby Tables.
Re:JSONx is an IBM standard format to represent JSON as XML by sp332 on Tuesday September 23, 2014 @05:04PM (#8358236)
Probably, well hopefully, sure. But I want to know whether they did, and whether the technique is fragile.
Re:JSONx is an IBM standard format to represent JSON as XML by figglesonrails on Tuesday September 23, 2014 @02:14PM (#8357029)
I 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.
Re:JSONx is an IBM standard format to represent JSON as XML by rasz_pl on Tuesday September 23, 2014 @03:17PM (#8357527)
well, IBM does sell storage solutions.