Like the brnwdrng question, I'm looking for a way to search through a JSON-like object.
assuming my object structure is this:
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." }] };
I would like to get an object with id = "A".
I have tried all such things as:
$(TestObj.find(":id='A'"))
but nothing works.
Can anyone think of a way to get an element based on some criteria without using "everyone"?
jquery jquery-selectors
J. Ed Feb 14 2018-11-12T00: 00Z
source share