web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Keep order of attributes of a X++ class when serializing it to XML

(0) ShareShare
ReportReport
Posted on by 23

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?

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 62 Most Valuable Professional

#2
#ManoVerse Profile Picture

#ManoVerse 57

#3
Pallavi Phade Profile Picture

Pallavi Phade 49

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans