Similar to brnwdrng s question, I m looking for a way to search through a JSON-like object.
supposing my object s structure is like so:
TestObj = {
"Categories": [{
"Products": [{
"id": "a01",
"name": "Pine",
"description": "Short description of pine."
},
{
"id": "a02",
"name": "Birch",
"description": "Short description of birch."
},
{
"id": "a03",
"name": "Poplar",
"description": "Short description of poplar."
}],
"id": "A",
"title": "Cheap",
"description": "Short description of category A."
},
{
"Product": [{
"id": "b01",
"name": "Maple",
"description": "Short description of maple."
},
{
"id": "b02",
"name": "Oak",
"description": "Short description of oak."
},
{
"id": "b03",
"name": "Bamboo",
"description": "Short description of bamboo."
}],
"id": "B",
"title": "Moderate",
"description": "Short description of category B."
}]
};
我想要一个id为“A”的对象。
我试过各种各样的东西,比如:
$(TestObj.find(":id= A "))
但似乎什么都不管用。
有人能想出一种方法,在不使用每个标准的情况下,根据某些标准检索项目吗?