JSON.NET DeserializeXmlNode to XML Attributes -


how can convert json xml using json.net this:

{data : [{s1 :3, s2 :4}, {s1 :1, s2:9}]} 

to

<data s1="3" s2="4" /><data s1="1" s2="9" /> 

once you've parsed object, pass function this.

ienumerable<xelement> getattributeddataelements(jobject obj, string membername) {     return         jobject o in obj[membername].asjenumerable()         select createnode(membername, o); }  xelement createnode(string membername, jobject obj) {     return new xelement(membername,         jproperty m in obj.asjenumerable()         select createnode(m)     ); }  xobject createnode(jproperty member) {     var value = member.value;     switch (value.type)     {     case jtokentype.string:     case jtokentype.integer:         return new xattribute(member.name, value);     default:         // assuming others objects         return createnode(member.name, (jobject)value);     } } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -