Answer the question
In order to leave comments, you need to log in
How to pull specific data from json file?
Hello, I have this json file:
{
"relationships_followers": [
{
"title": "",
"media_list_data": [
],
"string_list_data": [
{
"href": "https://www.instagram.com/20rozok02",
"value": "20rozok02",
"timestamp": 1607203051
}
]
},
{
"title": "",
"media_list_data": [
],
"string_list_data": [
{
"href": "https://www.instagram.com/ildar.yusupov.1990",
"value": "ildar.yusupov.1990",
"timestamp": 1606909478
}
]
},
{
"title": "",
"media_list_data": [
],
"string_list_data": [
{
"href": "https://www.instagram.com/aitmahan.ernur",
"value": "aitmahan.ernur",
"timestamp": 1589734471
}
]
},
{
"title": "",
"media_list_data": [
],
"string_list_data": [
{
"href": "https://www.instagram.com/blyagafarov",
"value": "blyagafarov",
"timestamp": 1586728175
}
]
}
]
}
Answer the question
In order to leave comments, you need to log in
One way (Linq2Json), using the Json.Net library , which edward_freedom wrote about in the comments.
var jsonPath = "data.json";
using StreamReader reader = File.OpenText(jsonPath);
var jToken = JToken.ReadFrom(new JsonTextReader(reader));
var values =
jToken["relationships_followers"].Select(j =>
j["string_list_data"][0]["value"].ToObject<string>())
.ToArray();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question