将字符串解析为JSON时出现c#错误

时间:2013-05-03 03:18:47

标签: json parsing

当我尝试在c#程序中通过错误“从JsonReader读取JObject时出错”时,我有一些文本。当前JsonReader项不是对象:字符串。路径'',第1行,第6位

文本:

"data":[{"username":"sex","bio":"#u24e2kyu24d4u24e7pressionsninstagramsex@gmail.com","website":"","profile_picture":"http://images.ak.com/profiles/profile_37086_75sq_1363954517.jpg","full_name":"sex","id":"37086"}]

我的代码:

JObject obj = JObject.Parse(text);

我想在解析为JSON

时获取用户名值

1 个答案:

答案 0 :(得分:0)

我会在整个字符串周围添加一个{ }

即。将文字更改为:

{"data":[{"username":"sex","bio":"#u24e2kyu24d4u24e7pressionsninstagramsex@gmail.com","website":"","profile_picture":"http://images.ak.com/profiles/profile_37086_75sq_1363954517.jpg","full_name":"sex","id":"37086"}]}