Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Tagged XML format #12

Closed
TheMadButcher opened this issue Jul 2, 2013 · 2 comments
Closed

Tagged XML format #12

TheMadButcher opened this issue Jul 2, 2013 · 2 comments

Comments

@TheMadButcher
Copy link
Contributor

Hi,

I have some changes that implements a tagged XML format.
I use this in several of my projects where I need to use both JSON and SOAP services.

If you would like to review and add my code, please drop me a line :)

JSONTaggedXML sample

The following example document is a sample of the JSON structure.

{
  "name/surname":"John Smith",
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postal-code": 10021,
  },
  "IDs": [
    "2-111",
    "2-222"
  ],
  "additionalInfo": null,
  "remote": false,
  "height": 62.4,
  "ficoScore": "> 640"
}

The following output is the result of the transformed document to JSONTaggedXML.

<?xml version="1.0" encoding="UTF-8"?>
<JsonItem>
  <name type="json:string" name="name">John Smith</name>
  <address type="json:object" name="address">
    <streetAddress type="json:string" name="streetAddress">21 2nd Street</streetAddress>
    <city type="json:string" name="city">New York</city>
    <state type="json:string" name="state">NY</state>
    <postalCode type="json:number" name="postalCode">10021</postalCode>
  </address>
  <phoneNumbers type="json:array" name="phoneNumbers">
    <JsonItem type="json:string">212 555-1111</JsonItem>
    <JsonItem type="json:string">212 555-2222</JsonItem>
  </phoneNumbers>
  <additionalInfo type="json:null" name="additionalInfo" />
  <remote type="json:boolean" name="remote">false</remote>
  <height type="json:number" name="height">62.4</height>
  <ficoScore type="json:string" name="ficoScore">&gt; 640</ficoScore>
</JsonItem>

Regards,

TMB

@r-lyeh-archived
Copy link
Contributor

Sure. Send a pull request. I will merge it :)

@r-lyeh-archived
Copy link
Contributor

Merged

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants