C# Extract an exact value from a JSON file.

  • Thread starter Thread starter studysession
  • Start date Start date
S

studysession

Guest
I am fairly new to all things C#.
Sorry for making a JSON post as there are many and no matter how many I read, I cannot find the answer I am looking for.
I am all over the place and read so many examples that do not work for me, I am now just confused where to begin.

I made something where I can iterate through the entire file but not just return a specific value.

I have a JSON file with thousands of entries. In my example I am only going to show 3 entries.

First - I want to extract and print only the values for the ip that = 8.8.8.8. I will take those values and save them in a new file in a different format.

If I am unclear on what I am asking and need to add any more details, please ask.

My file: file1.json

[
{
"ip": "1.1.1.1",
"latitude": -33.494,
"longitude": 143.2104
},
{
"ip": "2.2.2.2",
"latitude": 48.8582,
"longitude": 2.3387
},
{
"ip": "8.8.8.8",
"latitude": 37.751,
"longitude": -97.822
}
]


Thank you - Keith

Continue reading...
 
Back
Top