Hi guys
I would like to serialize a X++ - class to XML in F&O
Here is my code snippet:
pObjectOrder is my X++ - Class using DataContract and DatatMemberAttribute
// -----
str serializedJSON = FormJsonSerializer::serializeClass( pObjectOrder );
var node = Newtonsoft.Json.JsonConvert::DeserializeXNode(serializedJSON, @"AUFTRAG");
str retXML = '<?xml version="1.0"?>' + node.ToString();
// -----
I did not find out to serialize it directly to XML, so I did use serialize it to JSON and then deserialize it to XML.
After serializing the object to JSON, I get the attributes already ordered by name and finally the same in the XML. But my customer expect the order of attributes in the XML like they were defined in the class.
Is there any way to keep th order in the XML or a way to serialize it directly into an XML instead of JSON first?