PHP函数json_decode将点后的零浮点值解码为int [英] PHP function json_decode decodes float value with zeros after point as int

查看:224
本文介绍了PHP函数json_decode将点后的零浮点值解码为int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JSON字符串,其中包含一些具有以下值的密钥:123.00.当我使用json_decode函数时,我得到的解码字符串的前一个键等于123,而不是123.00.有没有一种方法可以正确解码这些值而不用引号引起来?

I have a JSON string that contains some key with the following value: 123.00. When I use json_decode function I get the decoded string where the previous key equal to 123, not to 123.00. Is there a way to correct decode such values without wrapping into quotes?

推荐答案

当前作为PHP错误被提出:

This is currently being brought up as a PHP bug:

错误报告: https://bugs.php.net/bug.php ?id = 50224

将来,可能会提供通过options参数传递标志的功能,以进行更严格的键入.但是,目前,用引号将其包装就足够了.

In the future, there may be functionality to pass a flag through the options parameter for stricter typing. For now, however, wrapping it in quotes will have to suffice.

这篇关于PHP函数json_decode将点后的零浮点值解码为int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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