在我的 WooCommerce android 应用程序中,当我从 URL 获取时,我得到了类别响应mysite/wc-api/v3/products/categories
。我的要求是我需要以不同的方式获取类别和子类别。在我的回复中,我将类别和子类别放在一起。
响应中有什么方法或关键可以区分两者吗?
以下是我的回复:
{
"product_categories": [{
"id": 2016,
"name": "Accessories",
"slug": "accessories",
"parent": 0,
"description": "",
"display": "default",
"image": "https:\/\/s3.amazonaws.com\/appilywebstie\/uploads\/2016\/09\/09111142\/Salona-Bichona-Cotton-Kitchen-Apron-Set-1896-6241932-2-zoom.jpg",
"count": 1
}, {
"id": 2055,
"name": "Anklets",
"slug": "anklets",
"parent": 2016,
"description": "",
"display": "subcategories",
"image": "",
"count": 2
}, {
"id": 2014,
"name": "Bags",
"slug": "bags",
"parent": 0,
"description": "",
"display": "default",
"image": "https:\/\/s3.amazonaws.com\/appilywebstie\/uploads\/2016\/09\/15045015\/dicount.jpg",
"count": 0
}, {
"id": 2052,
"name": "Bangles",
"slug": "bangles",
"parent": 2015,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2068,
"name": "Bath and Body",
"slug": "bath-and-body",
"parent": 2017,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2017,
"name": "Beauty",
"slug": "beauty",
"parent": 0,
"description": "",
"display": "default",
"image": "https:\/\/s3.amazonaws.com\/appilywebstie\/uploads\/2016\/09\/01105455\/sexy-hd-hot-girls-wallpaper.jpg",
"count": 0
}, {
"id": 2058,
"name": "Belts",
"slug": "belts",
"parent": 2016,
"description": "",
"display": "subcategories",
"image": "",
"count": 1
}, {
"id": 2040,
"name": "Boots",
"slug": "boots",
"parent": 2013,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2023,
"name": "Bottomwear",
"slug": "bottomwear",
"parent": 2010,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2035,
"name": "Bottomwear",
"slug": "bottomwear-westernwear",
"parent": 2012,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2071,
"name": "Bra and Panty Set",
"slug": "bra-and-panty-set",
"parent": 2018,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2069,
"name": "Bras",
"slug": "bras",
"parent": 2018,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2086,
"name": "Camisoles",
"slug": "camisoles",
"parent": 2018,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2044,
"name": "Clutches",
"slug": "clutches",
"parent": 2014,
"description": "",
"display": "default",
"image": "",
"count": 20
}, {
"id": 2028,
"name": "Dresses",
"slug": "dresses",
"parent": 2012,
"description": "",
"display": "default",
"image": "",
"count": 26
}, {
"id": 2048,
"name": "Earrings",
"slug": "earrings",
"parent": 2015,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2010,
"name": "Ethnic",
"slug": "ethnic",
"parent": 0,
"description": "",
"display": "default",
"image": "https:\/\/s3.amazonaws.com\/appilywebstie\/uploads\/2016\/09\/15054330\/Ethnic.jpg",
"count": 3
}, {
"id": 2064,
"name": "Eyes",
"slug": "eyes",
"parent": 2017,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2065,
"name": "Face",
"slug": "face",
"parent": 2017,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2038,
"name": "Flats",
"slug": "flats",
"parent": 2013,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2039,
"name": "Flip Flops",
"slug": "flip-flops",
"parent": 2013,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2062,
"name": "Hair Accessories",
"slug": "hair-accessories",
"parent": 2016,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2067,
"name": "Haircare",
"slug": "haircare",
"parent": 2017,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2047,
"name": "Handbags",
"slug": "handbags",
"parent": 2014,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2043,
"name": "Heels",
"slug": "heels",
"parent": 2013,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2033,
"name": "Jeans",
"slug": "jeans",
"parent": 2012,
"description": "",
"display": "default",
"image": "",
"count": 1
}, {
"id": 2015,
"name": "Jewellery",
"slug": "jewellery",
"parent": 0,
"description": "",
"display": "default",
"image": "https:\/\/s3.amazonaws.com\/appilywebstie\/uploads\/2016\/09\/09105848\/Moedbuille-Blue-Alloy-Danglers-26-Drop-8028-7838022-1-zoom.jpg",
"count": 0
}, {
"id": 2056,
"name": "Jewellery Sets",
"slug": "jewellery-sets",
"parent": 2015,
"description": "",
"display": "default",
"image": "",
"count": 2
}, {
"id": 2029,
"name": "Jumpsuits",
"slug": "jumpsuits",
"parent": 2012,
"description": "",
"display": "default",
"image": "",
"count": 4
}, {
"id": 2019,
"name": "Kurtis",
"slug": "kurtis",
"parent": 2010,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2022,
"name": "Lehengas",
"slug": "lehengas",
"parent": 2010,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2018,
"name": "Lingerie",
"slug": "lingerie",
"parent": 0,
"description": "",
"display": "default",
"image": "https:\/\/s3.amazonaws.com\/appilywebstie\/uploads\/2016\/09\/06072036\/881382626889.jpg",
"count": 0
}, {
"id": 2063,
"name": "Lips",
"slug": "lips",
"parent": 2017,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2054,
"name": "Maangtika",
"slug": "maangtika",
"parent": 2015,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2066,
"name": "Nails",
"slug": "nails",
"parent": 2017,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2051,
"name": "Necklaces",
"slug": "necklaces",
"parent": 2015,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2072,
"name": "Nightwear",
"slug": "nightwear",
"parent": 2018,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2053,
"name": "Noserings",
"slug": "noserings",
"parent": 2015,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2057,
"name": "Offbeat Jewellery",
"slug": "offbeat-jewellery",
"parent": 2015,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2070,
"name": "Panties",
"slug": "panties",
"parent": 2018,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2034,
"name": "Pants",
"slug": "pants",
"parent": 2012,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2049,
"name": "Pendants",
"slug": "pendants",
"parent": 2015,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2050,
"name": "Rings",
"slug": "rings",
"parent": 2015,
"description": "",
"display": "default",
"image": "",
"count": 3
}, {
"id": 2036,
"name": "Sandal",
"slug": "sandal",
"parent": 2013,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2020,
"name": "Sarees",
"slug": "sarees",
"parent": 2010,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2059,
"name": "Scarves",
"slug": "scarves",
"parent": 2016,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2025,
"name": "Shirts",
"slug": "shirts",
"parent": 2011,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2013,
"name": "Shoes",
"slug": "shoes",
"parent": 0,
"description": "",
"display": "default",
"image": "https:\/\/s3.amazonaws.com\/appilywebstie\/uploads\/2016\/09\/01111200\/Black1460634399.jpg",
"count": 0
}, {
"id": 2032,
"name": "Shorts",
"slug": "shorts",
"parent": 2012,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2031,
"name": "Skirts",
"slug": "skirts",
"parent": 2012,
"description": "",
"display": "default",
"image": "",
"count": 12
}, {
"id": 2085,
"name": "Sleepwear",
"slug": "sleepwear",
"parent": 2018,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2045,
"name": "Sling Bags",
"slug": "sling-bags",
"parent": 2014,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2037,
"name": "Slip Ons",
"slug": "slip-ons",
"parent": 2013,
"description": "",
"display": "default",
"image": "",
"count": 4
}, {
"id": 2041,
"name": "Sneakers",
"slug": "sneakers",
"parent": 2013,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2021,
"name": "Suits",
"slug": "suits",
"parent": 2010,
"description": "",
"display": "default",
"image": "",
"count": 31
}, {
"id": 2060,
"name": "Sunglasses",
"slug": "sunglasses",
"parent": 2016,
"description": "",
"display": "subcategories",
"image": "",
"count": 5
}, {
"id": 2024,
"name": "T Shirts",
"slug": "t-shirts",
"parent": 2011,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2011,
"name": "Tops",
"slug": "tops",
"parent": 0,
"description": "",
"display": "default",
"image": "https:\/\/s3.amazonaws.com\/appilywebstie\/uploads\/2016\/09\/15055420\/TOPS.jpg",
"count": 0
}, {
"id": 2026,
"name": "Tops",
"slug": "tops-tops",
"parent": 2011,
"description": "",
"display": "default",
"image": "",
"count": 10
}, {
"id": 2027,
"name": "Tunics",
"slug": "tunics",
"parent": 2011,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2046,
"name": "Wallets",
"slug": "wallets",
"parent": 2014,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2061,
"name": "Watches",
"slug": "watches",
"parent": 2016,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2042,
"name": "Wedges",
"slug": "wedges",
"parent": 2013,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2030,
"name": "Western Suits",
"slug": "western-suits",
"parent": 2012,
"description": "",
"display": "default",
"image": "",
"count": 0
}, {
"id": 2012,
"name": "WesternWear",
"slug": "westernwear",
"parent": 0,
"description": "",
"display": "default",
"image": "https:\/\/s3.amazonaws.com\/appilywebstie\/uploads\/2016\/09\/15054714\/BRANDS.jpg",
"count": 9
}]
}