var order = new JsonByPath(jsonString);
Example JSON:
{
"billing_address": {
"given_name": "Jane"
},
"order_amount": 5000,
"order_lines": [
{
"name": "Magz",
"available_attributes": {
["duration", "extras"]
}
}
]
}
var firstProductSecondAttribute = order.GetString("order_lines[0].available_attributes[1]", "");
// "extras"
var firstName = order.GetString("billing_address.given_name", "");
// "Jane"
var lastName = order.GetString("billing_address.family_name", "unknown");
// "unknown" (fallback)
var totalAmountIncTax = order.GetInt("order_amount", 0);
// 5000
var orderItemNames = order.GetArray("order_lines")
.Select(x => JsonByPath.Use(x).GetString("name", ""));
// IEnumerable<string> { "Magz" }