I am trying to extract the following fields from the JSON feed at the bottom of this post into a C# object.
"Bronze",
[
228,
380
]
C# Object Structure:
public Score
{
public string Grade {get;set;} // Bronze, Silver, Gold
public int PotentialPoints {get;set;} // First Integer
public int ActualPoints {get;set;} // Second Integer
}
The Feed
The string "Bronze" is variable, but the integer array structure will stay the same [X,X].
[
6,
[
[],
4,
{
"time crunch":[
"Bronze", <<< Trying to retrieve this node
[
228,
380
]
],
"3 rides":[
"Bronze", <<< Trying to retrieve this node
[
1418,
2730
]
],
"4 rides":[
"Bronze", <<< Trying to retrieve this node
[
180,
320
]
],
"[2 rides,2 runs]":[
"Silver", <<< Trying to retrieve this node
[
220,
270
]
]
}
]
]
2
Answers
This could be done a lot better but with the JSON you provided, it works …
Feel free to wait for other answers.
If your JSON has a standard schema, you can extract the data with JSON path.
Demo @ .NET Fiddle