function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ashok  45ashok 45 

How to Convert(Serialize) XML into JSON format?

Hi All,
    This is my sample XML data. I want to convert(Serialize) XML into JSON. Iam doing like this If am wrong please let me know.
 String xml= ' <?xml version="1.0" encoding="utf-16"?>
 <GETmethod xmlns:xsi="" xmlns:xsd="">
  <Extend />
      <SampleData />
 String JSONString = JSON.serialize(xml);
    I want to post it into future method, like below. will it take as JSON format or String format?
 ==> CalloutMethod(JSONString)
  public static void CalloutMethod(JSONString)
You cannot just use the serialize method on your XML.  You will need to convert the XML to an object by parsing it [1] and then serializing the created object.