Note that there are some explanatory texts on larger screens.

plurals
  1. PODataContract Serializer array node names 'd3p1'
    text
    copied!<p>Could someone tell me what the "d3p1" node name means in this?</p> <pre><code> &lt;ActionMessage&gt; &lt;Data xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"&gt; &lt;d3p1:anyType i:type="Agreement"&gt; &lt;/d3p1:anyType&gt; &lt;d3p1:anyType i:type="Agreement"&gt; shortened </code></pre> <p>I've received many "that looks ugly" and "what if d3p1 changes" comments on this the default serialization in my asp webapi project. I say it's machine readable just fine. But I am curious why it looks like this.</p> <p>Here are the details, I have a GET verb on the controller that returns an enumerable of <code>ActionMessage</code></p> <pre><code> public IEnumerable&lt;ActionMessage&gt; Get(Guid) </code></pre> <p><code>ActionMessage</code> can't be a generic (if that would even help) as the list would contain action messages of different generic types. "newagreement", "keychange", etc.</p> <p>It would look like <code>ActionMessage&lt;NewAgreement&gt;</code> or <code>ActionMessage&lt;KeyChange&gt;</code> and many more. There's no way to do this in the get as the get returns many "types" of action messages. Outside of a base class or interface. I.E. <code>ActionMessage&lt;IMessage&gt;</code> but these messages have nothing in common.</p> <p>Here's what action message looks like now.</p> <pre><code> public class ActionMessage { [DataMember] public Status Status { get; set; } [DataMember] [XmlElement(ElementName = "Agreement")] [XmlArrayItem(ElementName = "testnode")] public List&lt;object&gt; Data { get; set; } [DataMember] public MessageTypes Type { get; set; } [DataMember] public Guid Id { get; set; } } </code></pre> <p>Note the "troubled" XML comes from the data property.</p> <p>Thoughts? Should the XML human readability matter? Should I go through the pains of switching from the datacontract serializer to the xml serializer? This would likely enable the element name attributes, but I sort of prefer leaving this all vanilla, and while I could completely control the generated XML, do I really need to, or do I really care?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload