JsonSerializer serializer = new JsonSerializer();
jw.WritePropertyName("info");
serializer.Serialize(jw, res);
if (res[2] == true)
{
jw.WritePropertyName("healer"); jw.WriteStartObject();
jw.WritePropertyName("running");
jw.WriteValue(res[1] == true ? (checkBox1.IsChecked == true ? true : false) : false);
jw.WritePropertyName("main"); jw.WriteStartObject();
serializer.Serialize(jw, new bool[] { true, true, true, true, true, true });
jw.WriteEndObject(); // here
jw.WriteEndObject();
}
Could somebody tell me please why this code doesn’t work?
without line serializer.Serialize(jw, new bool[] {...}}); everything is working fine.
The cause of exception is that you are telling writer that you will write an object and you are writting an array. Try like this:
Or as an alternative like this: