c# - Serialize object without including property names -


i have simple object:

[datacontract] public class myclass {     [datamember(name = "myclassno")]     public int myclassno { get; set; }     [datamember(name = "myname")]     public string myname { get; set; }  } 

when serialize on web service get

[   {"myclassno": 1, "myname": "test1"},   {"myclassno": 2, "myname": "test2"} ] 

but want data without property names included:

[   {1, "test1"},   {2, "test2"} ] 

how achieve this?

*edit - code use serialize is:

var myobj = myopensqlconnection.query<myclass>(@"select myclassno, myname mytable"); return myobj.tolist<myclass>(); 

note i'm using dapper-dot-net map sql results object

it impossible without writing own serializer serializes other property hash. hashes sequences of key-value fields , therefore must have unique keys each field.

if tried blank values each key, in:

{"": "apple", "": "banana", "": "coconut"} 

then have just:

{"": "coconut"} 

since each key overwrite 1 before it.

a better question probably, "why want serialize without property names?" in web-based environments, you're going want know value corresponds field.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -