I deserialize a JSON from a third-party provider into an object and want to query that object looking for a value in a specific property.
My problem is that the object has a property (Parts) whose value is a list with the same type.
public class RulePartModel
{
public string isExistsUnder { get; set; }
public int State { get; set; }
public string Value { get; set; }
public List<RulePartModel> Parts { get; set; }
}
How can I query this object to find a specific Value when the Parts property can have 6 or 7 levels?
Here is a sample of the JSON I receive as an answer:
{
"isExistsUnder": null,
"State": "",
"Value": "CustomElements",
"Parts": [
{
"isExistsUnder": null,
"State": 0,
"Value": "Rule 73",
"Parts": [
{
"isExistsUnder": null,
"State": "",
"Value": "For variable initializations",
"Parts": [
{
"isExistsUnder": null,
"State": "",
"Value": "cupis",
"Parts": [
{
"isExistsUnder": null,
"State":"",
"Value": "randomText1",
"Parts": []
},
{
"isExistsUnder": null,
"State":"",
"Value": "randomText2",
"Parts": []
},
{
"isExistsUnder": null,
"State":"",
"Value": "randomText3",
"Parts": []
}
]
}
}
}
}