c# - Serialise JSON color hex without quotes -


so sending values javascript array. array called data, has 2 elements, value , color, example:

var data = [{value:226,color:"#fffff"},{value:257,color:"#fffff"}]; 

the problem color should color: #fffff without &quot surrounding. c# follows:

[jsonobject(memberserialization.optin)] public class statsvalues {     [jsonproperty]     public int value { get; set; }     [jsonproperty]     public string color { get; set; } }  var values = new list<studentbrandsapp.models.statsvalues>(); foreach (datarow dr in statsdatatable.rows) {     values.add(new studentbrandsapp.models.statsvalues() { value = convert.toint32(dr.itemarray[1].tostring()), color = "#fffff" }); }          var serializer = new jsonserializer();         var stringwriter = new stringwriter();         var writer = new jsontextwriter(stringwriter);         writer.quotename = false;         serializer.serialize(writer, values);         writer.close();         var json = stringwriter.tostring();         viewdata["json"] = json;  

how serialise color excludes quotes , returns hash value?

please try json string below format:

{   "array": [   {       "value":226,      "color":"#fffff"           },    {       "value":226,      "color":"#fffff"           }   ] } 

or

var data = [{"value":226,"color":"#fffff"},{"value":257,"color":"#fffff"}]; 

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? -