At first, my question might sound unclear. I'm new to JSON, but let me explain.
I have the following JSON file (which I can't modify):
{
"jsonexample": [
{
"Name": "Test1",
"Text": "This is test 1.",
"TestNumber": 1
},
{
"Name": "Test2",
"Text": "This is test 2.",
"TestNumber": 2
}
]
}
How can I find TestNumber based on Name?
This code doesn't work:
console.log(jsonexample.Name.Test1.TestNumber);
I thought it would give me 1 from the Test1 name data.
What would be the code which would be able to get the TestNumber data by giving the Name information only?
Edit: How could I make this work for a JSON WebPage : an API ?