I'm trying to parse a simple JSON string
[{"url":"http://loyalty.bosselman.com/Home/tabid/57/Default.aspx","position":"0","roles":"All Users;Administrators;"}]
You can find it here
[
loyalty.bosselman.com...]
When I run this code
var baseUrl = "http://loyalty.bosselman.com/DesktopModules/MyServices/API/Welcome/GetMenu?key";
WebClient client = new WebClient();
var data = client.DownloadString(baseUrl);
var obj = JsonConvert.DeserializeObject(data);
JObject job = JObject.Parse(obj.ToString());
foreach (JProperty prop in job.Properties())
{
Response.Write(prop["url"]);
}
I get this error
Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path '', line 1, position 1.
If I inspect my obj element it looks like this
"[{\"url\":\"http://loyalty.bosselman.com/Home/tabid/57/Default.aspx\",\"position\":\"0\",\"roles\":\"All Users;Administrators;\"}]"
I'm not sure why the \" are getting in there and obj.replace("\\", ""); does not remove them. What am I doing wrong?