I’m working on a library to parse Minecraft JSON files. However, they have a slightly weird format that I can’t figure out how to parse with Newtonsoft’s JSON.net:
{
"values": [
"some_object",
"another_object",
{
"name": "third_object",
"required": false
}
]
}
The class I’m trying to deserialize the values
array into looks like this:
class TagValue
{
public string Name;
public bool Required = false;
}
So for values which are just a string, it should set Name
to the string and leave Required
as false.
Is there a way I can do this? I’m very new to the library and can’t figure out how to do anything more advanced than the most basic deserialization.
2
Answers
Try this
Then presumably you have/need a class for the outer object:
PS – You also should make those fields properties as was suggested in the comments.
you don’t need any converters, just one string of code is plenty