'c#/json.net deserialize child with data from parent
class Item
{
public string Id;
public List<Item> Children;
}
json
{
"Id" : "/parent",
"Children" : [
{
"Id" : "/child1"
}
]
}
I have class for creating nested items. How would I have a child item access the parent's Id field during/after deserialization of the child? Or is there a way to send the parent Id field when the child is to be created?
Example: Parent Id "/parent" Child Id "/child1" I want the child Id "/parent/child1"
For reasons, I cannot use '[OnDeserialized]' after the parent is finished to loop children and change Id. Nor do I have access to change the json files themselves.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|