Java Reference
In-Depth Information
<phone>
<phone> 978-555-2233 </phone>
</phone>
< /customer
would look like the following in JSON:
{ "customer"
"customer" :
{ "phone"
"phone" : [ { "$"
"$" , "978-666-5555"
"978-666-5555" }, { "$"
"$" , "978-555-2233"
"978-555-2233" } ] }
}
4. XML attributes become JSON properties prefixed with the @ character. So, if you had
the XML:
<customer
<customer id= "42" >
<name>
<name> Bill Burke </name>
</name>
</customer>
the JSON mapping would look like the following:
{ "customer"
"customer" :
{ "@id"
"@id" : 42 ,
"name"
"name" : "Bill Burke"
}
}
5. Active namespaces are contained in an @xmlns JSON property of the element. The
“$” represents the default namespace. All nested elements and attributes would use
the namespace prefix as part of their names. So, if we had the XML:
<customer
<customer xmlns= "urn:cust" xmlns:address= "urn:address" >
<name>
<name> Bill Burke </name>
</name>
<address:zip>
<address:zip> 02115 </address:zip>
</address:zip>
</customer>
the JSON mapping would be the following:
{ "customer"
"customer" :
{ "@xmlns"
"@xmlns" : { "$"
"$" : "urn:cust" ,
"address"
"address" : "urn:address" } ,
"name"
"name" : { "$"
"$" : "Bill Burke" ,
"@xmlns"
"@xmlns" : { "$"
"$" : "urn:cust" ,
"address"
"address" : "urn:address" } },
"address:zip"
"address:zip" : { "$"
"$" : "02115" ,
"@xmlns"
"@xmlns" : { "$"
"$" : "urn:cust" ,
"address"
"address" : "urn:address" }}
}
}
Search WWH ::




Custom Search