Why use CJSON encode when we have json_encode

后端 未结 4 410
不思量自难忘°
不思量自难忘° 2021-01-01 09:33

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 addition

4条回答
  •  青春惊慌失措
    2021-01-01 10:08

    In addition to @kuldeep.kamboj, I should say CJSON::encode will treat that 17 as an integer if you define the data type of the value like this:

    // PHP
    $toBeConverted = array('id' => (int) 17); // or (int) $myInteger
    
    $jsonString = \CJSON::encode($toBeConverted);    
    
    // $jsonString will be:
    {
        "id": 17
    }
    

提交回复
热议问题