c# – 使用JSON中的冒号解析字段名称
发布时间:2020-12-15 19:38:57 所属栏目:百科 来源:网络整理
导读:如果json字段包含冒号(:),我们如何解析?像这样: { "dc:creator":"Jordan,Micheal","element:publicationName":"Applied Ergonomics","element:issn":"2839749823"} 事实上,我想知道如何使用像restsharp这样的库进行映射? 解决方法 使用 Json.Net string j
如果json字段包含冒号(:),我们如何解析?像这样:
{ "dc:creator":"Jordan,Micheal","element:publicationName":"Applied Ergonomics","element:issn":"2839749823" } 事实上,我想知道如何使用像restsharp这样的库进行映射? 解决方法
使用
Json.Net
string json = @"{ ""dc:creator"":""Jordan,Micheal"",""element:publicationName"":""Applied Ergonomics"",""element:issn"":""2839749823"" }"; var pub = JsonConvert.DeserializeObject<Publication>(json); public class Publication { [JsonProperty("dc:creator")] public string creator { set; get; } [JsonProperty("element:publicationName")] public string publicationName { set; get; } [JsonProperty("element:issn")] public string issn { set; get; } } 要么 Console.WriteLine(JObject.Parse(json)["dc:creator"]); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |