Why use CJSON encode when we have json_encode(当我们有 json_encode 时为什么要使用 CJSON 编码)
问题描述
我正在使用 Yii 为网站构建 API.我知道有一个名为 CJson 的实用程序类,并且有一个名为 encode 的函数.
I am building an API for a website using Yii. I know that there is a utility class called CJson and has a function called encode.
据我所知,还有一些额外的参数可以在原生 json_encode 函数中进行自定义,比如 JSON_NUMERIC_CHECK,这非常有用.它创造了
As far as I know there are additional parameters that can be customized in the native json_encode function like the JSON_NUMERIC_CHECK which is really useful. It creates
{
"id": 17
}
而不是 Yii 的 CJSON 编码,它使 '17' 成为一个字符串.
instead of Yii's CJSON encode which makes the '17' a string.
{
"id": "17"
}
所以我的问题是是否有任何理由我应该使用 CJSON 编码而不是内置的 PHP 函数 json_encode ?
So my question is whether there is any reason I should use CJSON encode instead of the built in PHP function json_encode ?
推荐答案
我能想到的只有最低 php 版本支持.
Only thing I can think minimum php version support.
Yii 支持 php 5.1 作为最低版本,请参阅 Yii 安装页面.而 json_encode/json_decode 在 php 5.2 中引入.所以这可能是 Yii 拥有 CJson 库的一个原因.
Yii support php 5.1 as minimum version See Yii Installation Page . While json_encode/json_decode introduced in php 5.2. So It can be a reason for Yii having a library for CJson.
这篇关于当我们有 json_encode 时为什么要使用 CJSON 编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:当我们有 json_encode 时为什么要使用 CJSON 编码


- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- PHP - if 语句中的倒序 2021-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01