Does Yii have a package for implementing JSON from Javascript?

Hi all, do you know if Yii has a package which implements the json2.js library from Douglas Crockford, or similar?

I am thinking in something like:

Yii::app()->getClientScript()->registerCoreScript('jquery', CClientScript::POS_HEAD);

but as:

Yii::app()->getClientScript()->registerCoreScript('json', CClientScript::POS_HEAD);

I need to use this from within Javascript code, not PHP, in one of the views.

thanks in advance

Fernando Gabrieli

NOTE: the Yii 1.0.x version is not maintained anymore… are you using it… as you posted in Yii 1.0.x forum ?

As for the core JS classes just take a look at the framework source code in /framework/web/js/source - there are all the core JS scripts…

So what to do if there is not the file you need?

Just download that file… put it in a web accessible folder and use registerScript() instead of registerCoreScript()

mdomba, thank you very much for your answer. I will do as you say, also will change forums since i didn’t realize i was posting to the wrong one.


registerCoreScript is for declaring usage of scripts that are shipped with (built-in) Yii.

If you need to use any external javascript / css (including your own), download it and use registerScriptFile method.

If you want to register custom (external) scripts the way you use buil-in (core), see registerPackage