c# - Custom serializing nested collection objects -
i trying serialize c# object restsharp's xmlserializer.
my model is:
public class person { public string name { get; set; } public list<address> addresses { get; set; } } public class address { public string city { get; set; } }
client code this, nothing fancy here.
list<address> addresses = new list<address>(); addresses.add(new address { city = "ny" }); addresses.add(new address { city = "istanbul" }); person person = new person { name = "mike", addresses = addresses }; console.writeline(new restsharp.serializers.xmlserializer().serialize(person));
the output is, expected, this:
<person> <name>mike</name> <addresses> <address> <city>ny</city> </address> <address> <city>istanbul</city> </address> </addresses> </person>
is there way following result? ("addresses" element names removed)
<person> <name>mike</name> <address> <city>ny</city> </address> <address> <city>istanbul</city> </address> </person>
Comments
Post a Comment