Sorry for my English. I have a Json Array :
"computers":
[
{
"id": 1,
"type": "laptop",
"manufactor":
[
{
id: "m_1",
name: "HP"
},
{
id: "m_2",
name: "Sony"
}
]
},
{
"id": 2,
"type": "desktop",
"manufactor":
[
{
id: "m_3",
name: "Apple"
},
{
id: "m_4",
name: "Tiger"
}
]
}
]
Could you tell me how can I do it like this: load computers data >> get 2 computer id 1 and 2 >> choose computer id = 1 >> load the manufactor of that computer. I can do it with mysql query but in json i don't know how to do that. Thanks for Suggestion!
Edit: I want to retrieve the manufacturer of the computer with ID - 1 from the JSON object above.
Thank to everyone for helping me out. I am going to create a page working with JSON look like DOJOX Rolling list, would you give me example or suggestion how to do like that ? thank you:D
Using:
computers[0].manufactor[0].name
Will return "HP".
If you change it to:
computers[0].manufactor[1].name
You will get "Sony".
Changing it further to:
computers[1].manufactor[0].name
will return "Apple".
And finally:
computers[1].manufactor[1].name
returns "Tiger".
Look here for more information on how to manipulate JSON objects with Javascript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With