如果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"]);