试图从我的数组中获取数据Jobjectpublic PostModel GetOnePost(PostModel postmodel, string token) { JObject response = context.GetOnePost(postmodel, token); PostModel post = new PostModel(); post.Title = response.SelectToken("title").Value<string>(); post.Content = response.SelectToken("content").Value<string>(); post.Urgency = response.SelectToken("urgency").Value<string>(); post.Slug = response.SelectToken("slug").Value<string>(); post.Completed = response.SelectToken("completed").Value<bool>(); return post; }我想从数据数组中获取标题...我该怎么做?这也不起作用 response.SelectToken("data.title"){{ "success": true, "msg": "Post received", "data": { "postId": "91207a39-6faa-4372-86dc-c5aa6e9f720c", "title": "End me", "content": "please", "slug": "end-me", "urgency": "low", "completed": false, "createdAt": "2019-04-23T08:26:18.988Z", "updatedAt": "2019-04-23T08:26:18.988Z", "clientClientId": "f379f920-a6f9-45b0-95c8-5f91138fb7a5", "tags": [] }}} Newtonsoft.Json.Linq.JToken {Newtonsoft.Json.Linq.JObject}
1 回答
侃侃尔雅
TA贡献1801条经验 获得超16个赞
如果你想获取tagsas JSON 数组,你可以执行以下操作
JObject response = context.GetOnePost(postmodel, token);
JArray array = JArray.Parse(response["data"]["tags"].ToString());
要获取title和content作为字符串,您可以执行以下操作
JObject response = context.GetOnePost(postmodel, token);
PostModel post = new PostModel();
post.Title = response["data"]["title"].ToString();
post.Content = response["data"]["content"].ToString();
.
.
.
- 1 回答
- 0 关注
- 65 浏览
添加回答
举报
0/150
提交
取消