Deserializing JSON when fieldnames contain spaces
问题 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", ".NET version": "4.0", "binding type": "HTTP", The field names contain spaces and other characters (the .) that are invalid in C# identifiers. What is the correct way to do this? (Unfortunately I don't have the option of changing the JSON format.) 回答1: Use the JsonProperty attribute to indicate the name in the JSON. e.g. [JsonProperty