Functions - jsonutils

fromXML
Converts an XML object to its JSON representation.

fromXML

(xml x, XmlOptions options)

returns json | error
Converts an XML object to its JSON representation.
 xml xmlValue = xml `<!-- outer comment -->` + xml `<name>supun</name>`;
 json|error jsonValue = fromXML(mxlValue);

Parameters

  • x xml
  • The XML source to be converted to JSON

  • options XmlOptions (default ballerina/jsonutils:XmlOptions $mapping$var$0 = {})
  • The XmlOptions record consisting of the configurations for the conversion

  • Return Type

    (json | error)
  • The JSON representation of the given XML on success, else returns an error