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
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:
CJSON::encode
17
data type
// PHP $toBeConverted = array('id' => (int) 17); // or (int) $myInteger $jsonString = \CJSON::encode($toBeConverted); // $jsonString will be: { "id": 17 }