You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With two consecutive comments in the source XML, the comment text is lost in JSON.
var xml = XElement.Parse("<bar> <!-- comment text --></bar>");
var json = Newtonsoft.Json.JsonConvert.SerializeXNode(xml); // produces {"bar":{/* comment text */}}
whereas
var xml = XElement.Parse("<bar><!-- comment1 --> <!-- comment2 --></bar>");
var json = Newtonsoft.Json.JsonConvert.SerializeXNode(xml); // produces {"bar":{"#comment":[]}}
Arguably, comments should never be emitted by SerializeXNode - Douglas Crockford has apparently stated that:
JSON does not have comments. A JSON encoder MUST NOT output comments. A JSON decoder MAY accept and ignore comments.
but as they are emitted, consistency seems to dictate that these three comments should all have their full comment text in the output.
The text was updated successfully, but these errors were encountered:
With two consecutive comments in the source XML, the comment text is lost in JSON.
whereas
Arguably, comments should never be emitted by SerializeXNode - Douglas Crockford has apparently stated that:
JSON does not have comments. A JSON encoder MUST NOT output comments. A JSON decoder MAY accept and ignore comments.
but as they are emitted, consistency seems to dictate that these three comments should all have their full comment text in the output.
The text was updated successfully, but these errors were encountered: