JSON_NUMERIC_CHECK根本行不通 [英] JSON_NUMERIC_CHECK simply won't work

查看:87
本文介绍了JSON_NUMERIC_CHECK根本行不通的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有两台服务器,一个本地开发服务器和一个实时服务器.我们的本地服务器运行PHP 5.4,我们的实时服务器运行PHP 5.5.3.

We've got two servers, a local development and a live server. Our local server runs PHP 5.4 and our live server runs PHP 5.5.3.

我们的图形数据无法正常工作,在仔细检查之后,json_encode()提供的数字数据中有引号.显然,调用的第一个端口是确保将JSON_NUMERIC_CHECK设置为第二个参数.问题是,设置了JSON_NUMERIC_CHECK,并且在开发服务器上json_encode()中的数据正确(数字数据上没有引号),但实时数据(引用了数字数据)上不正确,因此看来JSON_NUMERIC_CHECK无法正常工作.我检查了我的日志,那里没有任何线索,我根本没有任何想法.我已经在Google和Google上搜索了,什么都没有.

Our graph data isn't working, and after closer inspection, there are quotes in numeric data provided by json_encode(). Obviously the first port of call is to ensure JSON_NUMERIC_CHECK is set as the second parameter. Problem is, that JSON_NUMERIC_CHECK is set, and the data from json_encode() is correct on the dev server (no quotes on numeric data), but not the live (numeric data is quoted), so it appears that JSON_NUMERIC_CHECK isn't working. I've checked my logs, no clues there, I literally have no ideas at all. I've googled and googled, nothing.

我缺少PHP扩展程序吗?所有更新都已安装,已卡住.下面的代码段,尽管我看不到有什么帮助.

Am I missing a PHP extension or something? All updates ARE installed, stumped. Code snippet below, although I can't see it being any help.

// Provides an array of objects, tested, data is fine here
$data = new graph_data();
$json_data = json_encode($data, JSON_NUMERIC_CHECK);

//... Further down the application
echo $json_data;

推荐答案

我已经解决了这个问题.如果有人遇到这个问题,它的排序非常简单(我不敢相信我一开始就没有这样做!)

I've fixed this now. If anyone else comes across this, its really simple to sort (I can't believe I didn't do this in the first instance!)

您需要使用通常的命令安装一个名为"php5-json"的软件包:

You need to have a package called 'php5-json' installed, using the usual command:

sudo apt-get install php5-json

谢谢Ste.

这篇关于JSON_NUMERIC_CHECK根本行不通的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆