I am finding the best way to get part of JSON string instead of JTOken collection using SelectTokens(JPath).
For example :
JObject o = JObject.Parse(@"{
'Stores': [
'Lambton Quay',
'Willis Street'
],
'Manufacturers': [
{
'Name': 'Acme Co',
'Products': [
{
'Name': 'Anvil',
'Price': 50
}
]
},
{
'Name': 'Contoso',
'Products': [
{
'Name': 'Elbow Grease',
'Price': 99.95
},
{
'Name': 'Headlight Fluid',
'Price': 4
}
]
}
]
}");
List<JToken> manufactures = o.SelectTokens("Manufacturers");
I need output JSON string instead of a collection of JToken.
Expected output :
{
"Manufacturers": [
{
"Name": "Acme Co",
"Products": [
{
"Name": "Anvil",
"Price": 50
}
]
},
{
"Name": "Contoso",
"Products": [
{
"Name": "Elbow Grease",
"Price": 99.95
},
{
"Name": "Headlight Fluid",
"Price": 4
}
]
}
]
}
Is there any way to get output like this?