I'm working with a object in C#.
public class City
{
public int id { get; set; }
public string label { get; set; }
}
I need to create a JSONP file. I hope to get something like this
Places({"id": 1, "label": "London"}, {"id": 2, "label": "Paris"})
I tried use
JsonSerializer serializer = new JsonSerializer(); ´
JavaScriptSerializer s = new JavaScriptSerializer();
using (StreamWriter file = File.CreateText("myJson.json"))
{
serializer.Serialize(file, string.Format("{0}({1})", "Places", s.Serialize(places)));
file.Close();
}
But my result file is this:
"Places([{\"id\":1,\"label\":\"London\"}, {\"id\":2,\"label\":\"Paris\"}])"
And this result does not working for my for the ' \" ' chars