Issue
I dont know how to correctly say it, that´s why i wrote "pass" (please correct me). What i am trying to do is to retrieve a value from an JSON object depending on another variable value
This is the code
WebClient client = new WebClient();
string list = client.DownloadString("https://linkto.json");
dynamic json = JsonConvert.DeserializeObject(list);
var2 = json.variable[0].image;
It needs to read the variable value where it says "variable" but im not sure if this is possible or if it´s done in another way
Another edit: The "variable" on the code is where the variable should be read, i don't know either how to make it to read the value or anything
I tried searching on this forum and on the internet but im not sure what to search or what should i use
Thanks in advance for any answer!
Edit:
Here is the JSON string
{
"Person1": [
{
"image": "http://linktoimage.com",
"icon": "http://linktoicon.com",
"background": ""
}
],
"Person2": [
{
"image": "https://linktoimage",
"icon": "",
"background": "no-background"
}
]
}
A short example of the JSON string
Another edit: The JSON string can change over time, with new arrays
Solution
So i managed to do this by modifying the JSON format, i did it like this
{"People":[
{
"name": "",
"icon": "",
"background": ""
},
{
"name": "",
"icon": "",
"background": ""
},
{
"name": "",
"icon": "",
"background": ""
}]
}
So then I can use Foreach to get to the value
Answered By - MrCoolAndroid Answer Checked By - Clifford M. (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.