Skip to content

Instantly share code, notes, and snippets.

@webdesignberlin
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webdesignberlin/737ba1d561b385050a4b to your computer and use it in GitHub Desktop.
Save webdesignberlin/737ba1d561b385050a4b to your computer and use it in GitHub Desktop.
JSONx-Konvertierungsbeispiel
JSONx conversion example
This topic introduces a JSONx conversion example.
The following example document is a sample of the JSON structure.
...
{
"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"
}
The following output is the result of the transformed document as JSONx.
...
<?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>
JSON identifiers are represented by the string contents in the name attribute. Most Unicode characters are valid within identifiers, as long as they are properly escaped (for example, \unnnn). Identifiers must not be European Computer Manufacturers Association (ECMA) reserved words. DataPower® appliances do not validate JSON property names beyond the JSON specification.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment