SFU.getJSONObjectFromXml()
- Last UpdatedJun 25, 2024
- 1 minute read
Use getJSONObjectFromXml() method to convert an XML string to a JSON object.
Syntax
sRetVal = SFU.getJSONObjectFromXml(xmlString);
Parameters
|
Parameter |
Description |
|---|---|
|
xmlString |
XML string to convert to JSON object. |
Return Value
This method returns a JSON object.
Example
// Define an XML string.
var xmlString = "<MyRoot><FirstName>John</FirstName><LastName>Smith</LastName></MyRoot>";
// Convert the XML string to a JSON object.
var jsonObj = SFU.getJSONObjectFromXml(xmlString);
// The JSON object will be returned as:
// {
// "MyRoot" : {
// "FirstName":"John",
// "LastName":"Smith",
// }