Deserializing JSON when fieldnames contain spaces

后端 未结 4 1939
野性不改
野性不改 2020-12-31 05:11

I\'m writing a tool to read JSON files. I\'m using the NewtonSoft tool to deserialize the JSOn to a C# class. Here\'s an example fragment:

 \"name\": \"Fubar         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-31 05:46

    Use the JsonProperty attribute to indicate the name in the JSON. e.g.

    [JsonProperty(PropertyName = "binding type")]
    public string BindingType { get; set; }
    

提交回复
热议问题