繁体   English   中英

如何像这样转换 json 数组以查看 laravel

[英]how to convert json array like this to view laravel

我尝试使用解码但总是有错误 json_decode() 期望参数 1 是字符串,给定数组

` {"status":{"timestamp":"2020-11-26T12:19:43.442Z","error_code":0,"error_message":null,"elapsed":12,"credit_count":1,"notice ":null,"total_count":3841},"data":[{"id":1,"name":"Bitcoin","symbol":"BTC","slug":"bitcoin","num_market_pairs" :9535,"date_added":"2013-04-28T00:00:00.000Z","tags":["mineable","pow","sha-256","价值存储","state-渠道"],"max_supply":21000000,"circulating_supply":18554631,"total_supply":18554631,"platform":null,"cmc_rank":1,"last_updated":"2020-11-26T12:18:02.000Z" ,"quote":{"USD":{"price":17247.70801162772,"volume_24h":59005040595.46997,"percent_change_1h":0.03819689,"percent_change_24h":-10.66818958,"percent_change_7d":-2.58426346,"75_cap1:1"。 last_updated":"2020-11-26T12:18:02.000Z"}}},{"id":1027,"name":"Ethereum","symbol":"ETH","slug":"ethereum", "num_market_pairs":5769,"date_added":"2015-08-07T00:00:00.000Z","tags":["mineable","pow","smart-contract s"],"max_supply":null,"circulating_supply":113584879.624,"total_supply":113584879.624,"platform":null,"cmc_rank":2,"last_updated":"2020-11-26T12:18:02.000Z" ,"quote":{"USD":{"price":515.9676158574783,"volume_24h":29731138661.457035,"percent_change_1h":1.4170852,"percent_change_24h":-14.25703562,"percent_change_7d":9.42588329,"market_cap":58606119537.05395,"last_updated ":"2020-11-26T12:18:02.000Z"}}},{"id":52,"name":"XRP","symbol":"XRP","slug":"xrp"," num_market_pairs":669,"date_added":"2013-08-04T00:00:00.000Z","tags":["medium-of-exchange","enterprise-solutions","binance-chain"],"max_supply ":100000000000,"circulating_supply":45348221180,"total_supply":99990853796,"platform":null,"cmc_rank":3,"last_updated":"2020-11-26T12:19:02.000Z","quote:" "USD":{"price":0.54209162288765,"volume_24h":23930358898.866245,"percent_change_1h":2.29364957,"percent_change_24h":-22.25604323,"percent_change_7d":87.81226505 ,"market_cap":24582890814.5343,"last_updated":"2020-11-26T12:19:02.000Z"}}}]}

`

首先执行 json_encode(),然后执行 json_decode(),看看你得到了什么。

您只需将方法json_decode中的第二个参数设置为true

比如: json_decode($json, true);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM