这是我的阵列。
http://pastebin.com/eTrJ2PVB
当我像这样返回这个数组时,我收到一个错误。
return \Response::json($response, 200, [], JSON_NUMERIC_CHECK);
但是,当我删除JSON_NUMERIC_CHECK时,我得到了响应;但问题是我需要数值。
可以做些什么来解决这个问题?
答案 0 :(得分:0)
You don't mention what error you are getting, but I can't reproduce any errors either. In fact this code at http://pastebin.com/GJWrCgwN shows your array returned as a perfectly formatted JSON with literal numbers instead of strings - see results at http://pastebin.com/cYDzDGyE.
BTW, you can also use this alternative syntax where you don't need to mess with HTTP response status code or headers, just the JSON encoding options:
return response()->json($response)->setEncodingOptions(JSON_NUMERIC_CHECK);
Check it out at Symfony\Component\HttpFoundation\JsonResponse
.