REST API:URL 中的 JSON 个对象以获取自定义 JSON
REST API: JSON objects in URL to get custom JSON
我正在使用 cs-cart rest API 创建一个 android 应用程序。我的问题是我想要根据需要分类,例如父类别的 ID 为“0”,所以我只想要那个类别,我可以编辑 URL 以仅获取 parent_id:“0”的类别吗“
http://www.example.com/api/categories
我也试过 URL 使用不同的在线工具进行编码,但都没有用。
这是我现在得到的JSON,我需要具体的parent_id。
{
"categories": [
{
"category_id": "735",
"parent_id": "755",
"id_path": "60/755/735",
"category": "Clocks",
"position": "0",
"status": "A",
"product_count": "1",
"seo_name": "watches",
"seo_path": "60/755"
},
{
"category_id": "682",
"parent_id": "295",
"id_path": "217/295/682",
"category": "360° Video Camera",
"position": "0",
"status": "A",
"product_count": "514",
"seo_name": "360-video-camera",
"seo_path": "217/295"
},
{
"category_id": "413",
"parent_id": "0",
"id_path": "413",
"category": " Apparel",
"position": "0",
"status": "A",
"product_count": "2",
"seo_name": "apparel",
"seo_path": ""
},
{
"category_id": "359",
"parent_id": "217",
"id_path": "217/359",
"category": "Computers ",
"position": "0",
"status": "A",
"product_count": "25",
"seo_name": "computer-cables",
"seo_path": "217"
},
{
"category_id": "357",
"parent_id": "344",
"id_path": "217/344/357",
"category": "Chargers",
"position": "0",
"status": "A",
"product_count": "1154",
"seo_name": "network-media-converters",
"seo_path": "217/344"
},
{
"category_id": "355",
"parent_id": "344",
"id_path": "217/344/355",
"category": "Cellphones",
"position": "0",
"status": "A",
"product_count": "1469",
"seo_name": "gateways-controllers",
"seo_path": "217/344"
},
{
"category_id": "345",
"parent_id": "344",
"id_path": "217/344/345",
"category": "Bluetooth Accessories",
"position": "0",
"status": "A",
"product_count": "1052",
"seo_name": "network-antennas",
"seo_path": "217/344"
},
{
"category_id": "298",
"parent_id": "295",
"id_path": "217/295/298",
"category": "Camera Accessories",
"position": "0",
"status": "A",
"product_count": "507",
"seo_name": "camera-accessories",
"seo_path": "217/295"
},
{
"category_id": "296",
"parent_id": "295",
"id_path": "217/295/296",
"category": "Camcorders",
"position": "0",
"status": "A",
"product_count": "504",
"seo_name": "camcorders",
"seo_path": "217/295"
},
{
"category_id": "295",
"parent_id": "217",
"id_path": "217/295",
"category": "Cameras & Camcorders",
"position": "0",
"status": "A",
"product_count": "0",
"seo_name": "cameras-and-camcorders",
"seo_path": "217"
},
{
"category_id": "271",
"parent_id": "218",
"id_path": "217/218/271",
"category": "Audio Amplifiers",
"position": "0",
"status": "A",
"product_count": "1003",
"seo_name": "audio-amplifiers",
"seo_path": "217/218"
},
{
"category_id": "238",
"parent_id": "218",
"id_path": "217/218/238",
"category": "Bluetooth Music Receivers",
"position": "0",
"status": "A",
"product_count": "519",
"seo_name": "bluetooth-music-receivers",
"seo_path": "217/218"
},
{
"category_id": "218",
"parent_id": "217",
"id_path": "217/218",
"category": "Audio & Home Theatre",
"position": "0",
"status": "A",
"product_count": "1",
"seo_name": "audio-and-home-theatre",
"seo_path": "217"
},
{
"category_id": "188",
"parent_id": "779",
"id_path": "776/779/188",
"category": "Baby Furniture",
"position": "0",
"status": "A",
"product_count": "430",
"seo_name": "baby-furniture",
"seo_path": "776/779"
},
{
"category_id": "185",
"parent_id": "779",
"id_path": "776/779/185",
"category": "Baby Travel",
"position": "0",
"status": "A",
"product_count": "494",
"seo_name": "baby-travel",
"seo_path": "776/779"
},
{
"category_id": "169",
"parent_id": "779",
"id_path": "776/779/169",
"category": "Baby Bathing & Potting",
"position": "0",
"status": "A",
"product_count": "405",
"seo_name": "baby-bathing-and-potting",
"seo_path": "776/779"
},
{
"category_id": "109",
"parent_id": "108",
"id_path": "101/108/109",
"category": "BD/DVD Movies",
"position": "0",
"status": "A",
"product_count": "0",
"seo_name": "bd-dvd-movies",
"seo_path": "101/108"
},
{
"category_id": "90",
"parent_id": "85",
"id_path": "60/85/90",
"category": "Cups & Mugs",
"position": "0",
"status": "A",
"product_count": "504",
"seo_name": "cups-and-mugs",
"seo_path": "60/85"
},
{
"category_id": "83",
"parent_id": "69",
"id_path": "60/69/83",
"category": "Ceiling Lights",
"position": "0",
"status": "A",
"product_count": "592",
"seo_name": "ceiling-lighting",
"seo_path": "60/69"
},
{
"category_id": "70",
"parent_id": "69",
"id_path": "60/69/70",
"category": " Bulbs & Tubes ",
"position": "0",
"status": "A",
"product_count": "504",
"seo_name": "bulbs",
"seo_path": "60/69"
}
],
"params": {
"category_id": 0,
"visible": false,
"current_category_id": 0,
"simple": false,
"plain": true,
"limit": 0,
"item_ids": "",
"group_by_level": false,
"get_images": false,
"category_delimiter": "/",
"get_frontend_urls": false,
"max_nesting_level": null,
"get_company_name": false,
"items_per_page": 20,
"page": 1,
"except_id": 414,
"sort_order": "asc",
"sort_by": "position",
"sort_order_rev": "desc",
"total_items": "557"
}
}
如果您只想在 API 调用中获取 parent_id 为 0 的类别,请使用 URL:
http://www.example.com/api/categories?category_id=0&visible=true
当然,可以使用任何其他id代替0,只要确保添加&visible=true
参数即可。
我正在使用 cs-cart rest API 创建一个 android 应用程序。我的问题是我想要根据需要分类,例如父类别的 ID 为“0”,所以我只想要那个类别,我可以编辑 URL 以仅获取 parent_id:“0”的类别吗“
http://www.example.com/api/categories
我也试过 URL 使用不同的在线工具进行编码,但都没有用。
这是我现在得到的JSON,我需要具体的parent_id。
{
"categories": [
{
"category_id": "735",
"parent_id": "755",
"id_path": "60/755/735",
"category": "Clocks",
"position": "0",
"status": "A",
"product_count": "1",
"seo_name": "watches",
"seo_path": "60/755"
},
{
"category_id": "682",
"parent_id": "295",
"id_path": "217/295/682",
"category": "360° Video Camera",
"position": "0",
"status": "A",
"product_count": "514",
"seo_name": "360-video-camera",
"seo_path": "217/295"
},
{
"category_id": "413",
"parent_id": "0",
"id_path": "413",
"category": " Apparel",
"position": "0",
"status": "A",
"product_count": "2",
"seo_name": "apparel",
"seo_path": ""
},
{
"category_id": "359",
"parent_id": "217",
"id_path": "217/359",
"category": "Computers ",
"position": "0",
"status": "A",
"product_count": "25",
"seo_name": "computer-cables",
"seo_path": "217"
},
{
"category_id": "357",
"parent_id": "344",
"id_path": "217/344/357",
"category": "Chargers",
"position": "0",
"status": "A",
"product_count": "1154",
"seo_name": "network-media-converters",
"seo_path": "217/344"
},
{
"category_id": "355",
"parent_id": "344",
"id_path": "217/344/355",
"category": "Cellphones",
"position": "0",
"status": "A",
"product_count": "1469",
"seo_name": "gateways-controllers",
"seo_path": "217/344"
},
{
"category_id": "345",
"parent_id": "344",
"id_path": "217/344/345",
"category": "Bluetooth Accessories",
"position": "0",
"status": "A",
"product_count": "1052",
"seo_name": "network-antennas",
"seo_path": "217/344"
},
{
"category_id": "298",
"parent_id": "295",
"id_path": "217/295/298",
"category": "Camera Accessories",
"position": "0",
"status": "A",
"product_count": "507",
"seo_name": "camera-accessories",
"seo_path": "217/295"
},
{
"category_id": "296",
"parent_id": "295",
"id_path": "217/295/296",
"category": "Camcorders",
"position": "0",
"status": "A",
"product_count": "504",
"seo_name": "camcorders",
"seo_path": "217/295"
},
{
"category_id": "295",
"parent_id": "217",
"id_path": "217/295",
"category": "Cameras & Camcorders",
"position": "0",
"status": "A",
"product_count": "0",
"seo_name": "cameras-and-camcorders",
"seo_path": "217"
},
{
"category_id": "271",
"parent_id": "218",
"id_path": "217/218/271",
"category": "Audio Amplifiers",
"position": "0",
"status": "A",
"product_count": "1003",
"seo_name": "audio-amplifiers",
"seo_path": "217/218"
},
{
"category_id": "238",
"parent_id": "218",
"id_path": "217/218/238",
"category": "Bluetooth Music Receivers",
"position": "0",
"status": "A",
"product_count": "519",
"seo_name": "bluetooth-music-receivers",
"seo_path": "217/218"
},
{
"category_id": "218",
"parent_id": "217",
"id_path": "217/218",
"category": "Audio & Home Theatre",
"position": "0",
"status": "A",
"product_count": "1",
"seo_name": "audio-and-home-theatre",
"seo_path": "217"
},
{
"category_id": "188",
"parent_id": "779",
"id_path": "776/779/188",
"category": "Baby Furniture",
"position": "0",
"status": "A",
"product_count": "430",
"seo_name": "baby-furniture",
"seo_path": "776/779"
},
{
"category_id": "185",
"parent_id": "779",
"id_path": "776/779/185",
"category": "Baby Travel",
"position": "0",
"status": "A",
"product_count": "494",
"seo_name": "baby-travel",
"seo_path": "776/779"
},
{
"category_id": "169",
"parent_id": "779",
"id_path": "776/779/169",
"category": "Baby Bathing & Potting",
"position": "0",
"status": "A",
"product_count": "405",
"seo_name": "baby-bathing-and-potting",
"seo_path": "776/779"
},
{
"category_id": "109",
"parent_id": "108",
"id_path": "101/108/109",
"category": "BD/DVD Movies",
"position": "0",
"status": "A",
"product_count": "0",
"seo_name": "bd-dvd-movies",
"seo_path": "101/108"
},
{
"category_id": "90",
"parent_id": "85",
"id_path": "60/85/90",
"category": "Cups & Mugs",
"position": "0",
"status": "A",
"product_count": "504",
"seo_name": "cups-and-mugs",
"seo_path": "60/85"
},
{
"category_id": "83",
"parent_id": "69",
"id_path": "60/69/83",
"category": "Ceiling Lights",
"position": "0",
"status": "A",
"product_count": "592",
"seo_name": "ceiling-lighting",
"seo_path": "60/69"
},
{
"category_id": "70",
"parent_id": "69",
"id_path": "60/69/70",
"category": " Bulbs & Tubes ",
"position": "0",
"status": "A",
"product_count": "504",
"seo_name": "bulbs",
"seo_path": "60/69"
}
],
"params": {
"category_id": 0,
"visible": false,
"current_category_id": 0,
"simple": false,
"plain": true,
"limit": 0,
"item_ids": "",
"group_by_level": false,
"get_images": false,
"category_delimiter": "/",
"get_frontend_urls": false,
"max_nesting_level": null,
"get_company_name": false,
"items_per_page": 20,
"page": 1,
"except_id": 414,
"sort_order": "asc",
"sort_by": "position",
"sort_order_rev": "desc",
"total_items": "557"
}
}
如果您只想在 API 调用中获取 parent_id 为 0 的类别,请使用 URL:
http://www.example.com/api/categories?category_id=0&visible=true
当然,可以使用任何其他id代替0,只要确保添加&visible=true
参数即可。