反序列化JSON对象为C#对象 [英] Deserialize JSON object to C# object

查看:116
本文介绍了反序列化JSON对象为C#对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着去阅读使用RestSharp一些JSON数据。

Im trying to read some json data using RestSharp.

但有一些问题阅读JSON对象IM。
我有这个respons:

But im having some problems reading json objects. I have this respons:

expand: "html",
self: "<url>/INCIDENT-447",   
key: "INCIDENT-447",
fields: {
  customfield_11414: {
  name: "Corrective Measures",
  type: "com.atlassian.jira.plugin.system.customfieldtypes:textarea"
},
  summary: {
  name: "summary",
  type: "java.lang.String",
  value: "BLA BLA BLA"
},  

我需要创建具有属性的夏日和customfield_11414
一个对象,但我只需要其中的价值。不是整个JSON对象

I need to create a object with Property's summery and customfield_11414 But i only need the value of them. Not the entire JSON object

推荐答案

您可以使用 Json.Net 动态关键字一起

You can use Json.Net and dynamic keyword together

dynamic dynObj = JsonConvert.DeserializeObject(json);
Console.WriteLine(dynObj.fields.customfield_11414.name + " " + 
                  dynObj.fields.summary.value);

这篇关于反序列化JSON对象为C#对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆