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
Post a Comment