[英]I want to change a json format after fetching using javascript
我有一個像下面這樣的json ..獲取此json后,我將其存儲在一個名為data的變量中。我需要將此數據變量更改為以下
{ "recipes": [ { "cuisine": "chinese", "description": "hjkhdkd", "id": 3, "min_time": "30-60min", "name": "Noodles", "nutrition": "", "qty": "", "quantity_unit_id": "2", "rate": "", "recipe_type": "vegetarian", "serve": [ "4" ], "tip": "", "image_url": { "medium": "/system/recipes/images/000/000/003/medium/dfdfs.jpeg?1501851554" } } ] }
我如何使用JavaScript更改上述像波紋管這樣的json數據
[ { "cuisine": "chinese", "description": "hjkhdkd", "id": 3, "min_time": "30-60min", "name": "Noodles", "nutrition": "", "qty": "", "quantity_unit_id": "2", "rate": "", "recipe_type": "vegetarian", "serve": [ "4" ], "tip": "", "image_url": { "medium": "/system/recipes/images/000/000/003/medium/dfdfs.jpeg?1501851554" } } ]
var data = '{ "recipes": [ { "cuisine": "chinese", "description": "hjkhdkd", "id": 3, "min_time": "30-60min", "name": "Noodles", "nutrition": "", "qty": "", "quantity_unit_id": "2", "rate": "", "recipe_type": "vegetarian", "serve": [ "4" ], "tip": "", "image_url": { "medium": "/system/recipes/images/000/000/003/medium/dfdfs.jpeg?1501851554" } } ] }';
var jsonifieddata = JSON.parse(data);
var newdata = jsonifieddata.recipes;
JSON.stringify(newdata);
在控制台中運行。
一個建議:當您再次詢問stackoverflow時,分享您所付出的努力。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.