Parsing JSON with a space in the key name
I have a JSON structure like this which I'd like to parse to a class or struct:
{
"records":[
{
"id":"...",
"fields":{
"Name":"...",
"My URL":"..."
},
},
...
]
}
The field names are totally predictable, so it's not like I need to be able to deserialise a dictionary, which wouldn't be supported anyway... but how can I get the JSON parser to bind a name with a space on it to my class?
I tried this:
[Serializable]
public class SongFields
{
[SerializeField]
public string Name;
[FormerlySerializedAs("My URL")]
[SerializeField]
public string MyURL;
}
But it doesn't seem to set the URL field at all, even though the name seems like it should match.
If it isn't possible to use Unity's parser to do this, is there an alternative one which works? I tried to integrate fastJSON like someone had recommended for an earlier version of Unity, but it seems to use later language features than I have available.
Your answer
Follow this Question
Related Questions
How to serialize vector3 with JSON.net? 2 Answers
JsonUtils.ToJson alters the object?? 0 Answers
List of serializable class objects results in empty json 1 Answer
Exlcude fields from JsonUtility but still serialise them? 1 Answer
JsonUtility and Arrays - JSON must represent an object type. 0 Answers