I have this json string:
[
{f_id:100,r_id:200,count:2,c_id=111},
{f_id:120,r_id:200,count:1,c_id=111 }
]
i want to parse up json string with newtonsoft.json.
how can i do this?
I write this code:
private void button1_Click(object sender, EventArgs e)
{
string json = @"[
{f_id:100,r_id:200,count:2,c_id=111},
{f_id:120,r_id:200,count:1,c_id=111 }
]";
List<myClass> tmp = JsonConvert.DeserializeObject<List<myClass>>(json);
int firstFId = tmp[0].f_id;
label1.Text = firstFId.ToString();
label2.Text = tmp[1].f_id.ToString();
}
public class myClass
{
public int f_id { get; set; }
public int r_id { get; set; }
public int count { get; set; }
public int c_id { get; set; }
}
but have this error:
An unhandled exception of type 'Newtonsoft.Json.JsonReaderException' occurred in Newtonsoft.Json.dll
Additional information: Invalid JavaScript property identifier character: =. Path '[0].count', line 2, position 32.