c# - Bind items in generic list and Serialize -


this code:

list<test> list = new list<test>(); (int j = 0; j < dss.tables[0].rows.count; j++) {     list.add(new test(dss.tables[0].rows[j]["pset"].tostring(),                        convert.toint32(dss.tables[0].rows[j]["score"].tostring()))); } stringbuilder data = new stringbuilder(); javascriptserializer json = new javascriptserializer(); json.serialize(list, data); hdlinedata.value = list.tostring();    

but it's not serializing list, if not binding list correctly. please suggest me how bind list in json format.

you can use [serializable()] attribute on custom class , then:

javascriptserializer serializer = new javascriptserializer(); var json = serializer.serialize(myobject); 

to ignore specific properties in object you're serializing, place [nonserialized] attribure on them.

i referred here


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -