Tools, FAQ, Tutorials:
Mapping XML Attributes to JSON Values
What is the standard to map XML Attributes to JSON Values?
✍: FYIcenter.com
There seems to be no industry standard on how to map XML Attributes to JSON Values.
But there are some commonly used conventions:
1. Converting each XML attribute to a single JSON object property. The property name is set to the attribute name and the property value is set to the attribute value. For example:
XML: <div id="1001" class="banner"/> JSON: { "div": { "id": "1001", "class": "banner" } }
2. Prefixing XML attribute name with "@". To differentiate JSON object properties converted from XML attributes from XML sub elements, "@" is added to each XML attribute name. For example:
XML: <div id="1001" class="banner"/> JSON: { "div": { "@id": "1001", "@class": "banner" } }
3. Converting empty XML attributes to JSON properties with Null values. If the value of an XML attribute is an empty string, it is converted to the JSON Null value. For example:
XML: <div id="1001" class=""/> JSON: { "div": { "@id": "1001", "@class": null } }
2017-08-17, 658👍, 0💬
Popular Posts:
What is EPUB 2.0 Metadata "dc:date" Element? EPUB 2.0 Metadata "dc:date" is an optional metadata ele...
What Is an HTML http-equiv "meta" Tag/Element? a http-equiv "meta" element is a special "meta" eleme...
What is Azure API Management Gateway? Azure API Management Gateway is the Azure Web server that serv...
What Is HTML? HTML (HyperText Markup Language) is the standard markup language for creating Web page...
How to login to Azure API Management Publisher Dashboard? If you have given access permission to an ...