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.

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
}

instead of Yii's CJSON encode which makes the '17' a string.

{
    "id": "17"
}

So my question is whether there is any reason I should use CJSON encode instead of the built in PHP function json_encode ?

推荐答案

Only thing I can think minimum php version support.

Yii支持php5.1作为最低版本见Yii Installation Page.而在php 5.2中引入了json_encode/json_decode.所以这可能是YII为CJson建图书馆的一个原因.

Json相关问答推荐

抓取低于w jolt的对象级别

在Golang中从 struct 手动创建JSON对象

使用jq过滤复杂json对象中的数据

交换键和数组值,将旧键转换为新数组值,使用 jq

使用 Powershell,如何将 Azure AD 组成员转换为 Json 对象(文件),然后可以更新?

在 json 对象中存储多个键:值对

使用 TypeScript 接口时如何修复未定义错误?

如何在不使用 Newtonsoft.JSON 的情况下序列化/反序列化

使用 REACT 从字段值中读取 JSON 元素

将 JSON 解组为具有唯一元素的 map 切片

jq:来自嵌套 JSON 的映射

通过一个序列化器更新多个模型数据

在PowerShell中按时间戳过滤JSON

如何使用 Newtonsoft.Json 反序列化 JSON 数组

Rails:format.js 或 format.json,或两者兼而有之?

如何在 Eclipse 中安装和使用 JSON 编辑器?

json.decoder.JSONDecodeError:期望值:第 1 行第 1 列(字符 0)

在 JSON.stringify() 的输出中隐藏空值

如何判断 JSON 响应元素是否为数组?

如何在 JAVA 中对 JSONArray 进行排序