php使用json_decode后数字对象转换成了科学计数法的解决方法
发表于:2023-01-16 14:45:34浏览:541次
总结
若值是整型,则使用
json_decode($json, true , 512 , JSON_BIGINT_AS_STRING)若值是浮点型,则无解
若值是字符串型,则使用
json_decode($json, true)
示例
$str1 = '{"price":112233445566778899112233}';
// 使用:json_decode($str1, true)
// 输出:
// Array
// (
// [price] => 1.1223344556678E+23
// )
// 使用:json_decode($str1, true , 512 , JSON_BIGINT_AS_STRING)
// 输出:
// Array
// (
// [price] => 112233445566778899112233
// )
$str2 = '{"price":112233445566778899112233.85}';
// 使用:json_decode($str2, true)
// 输出:
// Array
// (
// [price] => 1.1223344556678E+23
// )
// 使用:json_decode($str2, true , 512 , JSON_BIGINT_AS_STRING)
// 输出:
// Array
// (
// [price] => 1.1223344556678E+23
// )
$str3 = '{"price":"112233445566778899112233.85"}';
// 使用:json_decode($str3, true)
// 输出:
// Array
// (
// [price] => 112233445566778899112233.85
// )
// 使用:json_decode($str3, true , 512 , JSON_BIGINT_AS_STRING)
// 输出:
// Array
// (
// [price] => 112233445566778899112233.85
// )
栏目分类全部>
推荐文章
- php列表数据转成树形结构
- mysql报错:1205 - Lock wait timeout exceeded; try restarting transaction
- 在宝塔上续签Let's Encrypt证书
- python模块安装包(长期更新)
- 微信商户支付配置
- php10进制转16进制(浮点数)
- php使用json_decode后数字对象转换成了科学计数法的解决方法
- fastadmin动态下拉SelectPage带条件筛选
- curl error 60 while downloading https://packagist.phpcomposer.com/packages.json: SSL certificate problem: certificate has expired
- php通过经纬度计算距离
