In JSON.Net I can read a JSON file into a data structure and then only convert the properties that I'm interested in to objects. For example, if I have a JSON file like
{
"Bob": {
"Steve": 5
}
}
I can get the object like so:
class SteveObject {
public int Steve;
}
var jsonSerializer = JsonSerializer.Create()
var jsonFile = JObject.Parse(text);
vat steveObject = jsonFile["Bob"].ToObject<SteveObject>(jsonSerializer)
How do I do the same thing with YAMLDotNet or SharpYaml? I.e. if I have a YAML file like
Bob:
Steve: 5
How do I reconstruct the SteveObject
from that without having to create the outer object?
Ok, I've written some code using SharpYaml that takes a simplified JPath query and returns the requested object.
Given the above YAML the following works:
Sure wish there were a library for this, though.