homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

Can't process json data

WebmasterWorld Senior Member 5+ Year Member

Msg#: 4623092 posted 11:30 pm on Nov 13, 2013 (gmt 0)

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


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



WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

Msg#: 4623092 posted 4:33 pm on Nov 15, 2013 (gmt 0)

When you are inspecting the string the \" are seeing are the escaped ". The slash are not actually in the string.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved