Skip to content
 
 

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Deploy to Salesforce

Apex-XML-Serializer

Serializes and Deserializes an Apex object to XML and vice versa. It also has functionality to convert between XML and Json.

Usage

Use the methods in the XMLSerializer class to perform round-trip XML serialization and deserialization of Apex objects.

XMLSerializer Methods

Following are the XMLSerializer methods.

-serialize(objectToSerialize)
Serializes Apex objects into XML content.

-serialize(objectToSerialize,suppressApexObjectNulls,addRootElementName)
Suppresses null values when serializing Apex objects into XML content and wraps entire content with 'addRootElementName' when supplied and ignores empty objects from serializing.

-deSerialize(xmlString, apexType)
Deserializes the specified XML string into an Apex object of the specified type.

-deSerialize(xmlString,apexType,deSerializeNodesAsArray)
Deserializes the specified XML string into an Apex object of the specified type and deserializes all elements specified in 'deSerializeNodesAsArray' as array.

-deSerializeUnTyped(xmlString)
Deserializes the specified XML string into collection of primitive data types.

-deSerializeUnTyped(xmlString,deSerializeNodesAsArray)
Deserializes the XML string into collection of primitive data types. All node names specified in 'deSerializeNodesAsArray' will be deserialized as arrays.

-XMLToJSON(xmlString)
Converts specified XML string into JSON string.

-XMLToJSON(xmlString,deSerializeNodesAsArray)
Converts specified XML string into JSON string and converts nodes specified in 'deSerializeNodesAsArray' as arrays.

-JSONToXML(jsonString)
Converts specified JSON string to XML.

-JSONToXML(jsonString,suppressNulls)
Converts specified JSON string to XML and ignores all empty tags if 'suppressNulls' is true.

Limitations

  • XML attributes are not supported.

Areas of interest/Future work

  • Ability to replace XML tag names : Often times we need xml tag names in a format that apex would not allow as variable names like one with special characters or reserved words. It would be useful to be able to replace them in the serialization or deserialization process.

About

XML Serialization and Deserialization in salesforce Apex.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages