We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
Is there a way to customize the array item names produced when converting from JSON to XML?
For example:
var json = @" [ { ""name"": ""John"", ""age"": 30, ""address"": { ""city"": ""New York"", ""street"": ""5th Avenue"", ""number"": 123 }, ""phones"": [ { ""type"": ""Home"", ""number"": ""123-456-7890"" }, { ""type"": ""Work"", ""number"": ""456-789-0123"" } ] } ]"; var sb = new StringBuilder(); using (var xml = new ChoXmlWriter(sb).Configure(x => { x.RootName = "root"; x.NodeName = "item"; x.UseXmlArray = true; x.DoNotEmitXmlNamespace = true; x.ThrowAndStopOnMissingField = false; })) using (var r = new ChoJSONReader(JToken.Parse(json))) { xml.Write(r); } Console.WriteLine(sb.ToString());
Produces:
<root> <item> <name>John</name> <age>30</age> <address> <city>New York</city> <street>5th Avenue</street> <number>123</number> </address> <phones> <phone> <type>Home</type> <number>123-456-7890</number> </phone> <phone> <type>Work</type> <number>456-789-0123</number> </phone> </phones> </item> </root>
But I need the individual phone nodes to have the tag name "item" like this:
<root> <item> <name>John</name> <age>30</age> <address> <city>New York</city> <street>5th Avenue</street> <number>123</number> </address> <phones> <item> <type>Home</type> <number>123-456-7890</number> </item> <item> <type>Work</type> <number>456-789-0123</number> </item> </phones> </item> </root>
This is just a simple example but I am trying to generically handle any json structure so I can't hardcode any rules or assume the shape of the data.
Thanks!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello,
Is there a way to customize the array item names produced when converting from JSON to XML?
For example:
Produces:
But I need the individual phone nodes to have the tag name "item" like this:
This is just a simple example but I am trying to generically handle any json structure so I can't hardcode any rules or assume the shape of the data.
Thanks!
The text was updated successfully, but these errors were encountered: