我知道这可能看起来像一个荒谬的问题,但我无法弄清楚为什么我收到的JSON响应从以下字符串开始(###){}
string(124) "tonce=1111111111111111&accesskey=2222222-4444-4444-bbbb-777777777777&requestmethod=post&id=1&method=getMarketDepth2¶ms=" {"method":"getMarketDepth2","params":[],"id":1}{ string(672) "{"result":{"market_depth":{"bid":[{"price":3500,"amount":7.198},{"price":3496,"amount":1},{"price":3495.5,"amount":0.02},{"price":3494.99,"amount":13},{"price":3492.81,"amount":1.21},{"price":3492.04,"amount":10},{"price":3492,"amount":6.561},{"price":3489.82,"amount":1.7},{"price":3489.81,"amount":31.8},{"price":3489.61,"amount":0.59}],"ask":[{"price":3510,"amount":166.405},{"price":3518.98,"amount":1.39},{"price":3519,"amount":24.002},{"price":3519.96,"amount":10.958},{"price":3519.98,"amount":0.09},{"price":3520,"amount":116.277},{"price":3520.1,"amount":5},{"price":3522,"amount":43.451},{"price":3522.79,"amount":0.002},{"price":3523,"amount":46.5}]}},"id":"1"}"
我是否有一种特殊方式可以解析这个或者我只是在开始和结束花括号之前删除所有内容
这是代码输出。
try {
$ticker = request('getMarketDepth2', array());
var_dump(request('getMarketDepth2', array()));
} catch (Exception $e) {
echo "Error:".$e->getMessage();
}
答案 0 :(得分:3)
它正在输出字符串(#length){},因为你正在使用var_dump()。请尝试使用echo。