When I try to convert JSON with only one property inside
{"abc":"123"}
for some reason it ignores options
<ObjectRootElementName>Root</ ObjectRootElementName>
and return XML like this
<abc>123</abc>
but if I try to pass JSON with more than one property it perfectly works. For example for the next JSON
{"abc":"123", "efg": "456"}
it returns expected XML
<Root><abc>123</abc><efg>456</efg></Root>
What could be the reason of behavior like this and how to prevent it?
Please confirm: Your expected return value in the first case is:
<Root><abc>123</abc></Root>
Yes, that's exact XML that I expected to get! 🙂
Did you solve this issue? I have the same situation here.
The solution, I guess, would be to have an additional policy
Ah, yes.
The documentation states:
<ObjectRootElementName> specifies the root element name when you convert from JSON, which does not have a named root element, to XML.
Based on this, I think the behavior you are reporting, is the expected behavior.