public static function makeJsonEncodable($objValue)
    {
        if (QCUBED_ENCODING == 'UTF-8') {
            return $objValue; // Nothing to do, since all strings are already UTF-8 and objects can take care of themselves.
        }

        switch (gettype($objValue)) {
            case 'string':
                $objValue = mb_convert_encoding($objValue, 'UTF-8', QCUBED_ENCODING);
                return $objValue;

            case 'array':
                $newArray = array();
                foreach ($objValue as $key => $val) {
                    $key = self::makeJsonEncodable($key);
                    $val = self::makeJsonEncodable($val);
                    $newArray[$key] = $val;
                }
                return $newArray;

            default:
                return $objValue;

        }
    }
public static function makeJsonEncodable($objValue)
    {
        if (QCUBED_ENCODING == 'UTF-8') {
            return $objValue; // Nothing to do, since all strings are already UTF-8 and objects can take care of themselves.
        }

        switch (gettype($objValue)) {
            case 'string':
                $objValue = mb_convert_encoding($objValue, 'UTF-8', QCUBED_ENCODING);
                return $objValue;

            case 'array':
                $newArray = array();
                foreach ($objValue as $key => $val) {
                    $key = self::makeJsonEncodable($key);
                    $val = self::makeJsonEncodable($val);
                    $newArray[$key] = $val;
                }
                return $newArray;

            default:
                return $objValue;

        }
    }
public static function makeJsonEncodable ( $ objValue ) { if ( QCUBED_ENCODING == 'UTF-8' ) { return $ objValue ; // Nothing to do, since all strings are already UTF-8 and objects can take care of themselves. } switch ( gettype ( $ objValue ) ) { case 'string' : $ objValue = mb_convert_encoding ( $ objValue , 'UTF-8' , QCUBED_ENCODING ) ; return $ objValue ; case 'array' : $ newArray = array ( ) ; foreach ( $ objValue as $ key => $ val ) { $ key = self :: makeJsonEncodable ( $ key ) ; $ val = self :: makeJsonEncodable ( $ val ) ; $ newArray [ $ key ] = $ val ; } return $ newArray ; default : return $ objValue ; } }
Convert an object to a structure that we can call json_encode on. This is particularly meant for the purpose of
sending json data to qcubed.js through ajax, but can be used for other things as well.

PHP 5.4 has a new jsonSerializable interface that objects should use to modify their encoding if needed. Otherwise,
public member variables will be encoded. The goal of object serialization should be to be able to send it
to qcubed.unpackParams in qcubed.js to create the javascript form of the object. This decoder will look for objects
that have the 'qObjType' key set and send the object to the special unpacker.

QDateTime handling is absent below. QDateTime objects will get converted, but not in a very useful way. If you
are using strict QDateTime objects (not likely since the framework normally uses QDateTime for all date objects),
you should convert them to QDateTime objects before sending them here.

@param mixed $objValue
@return mixed
@was MakeJsonEncodable
Convert an object to a structure that we can call json_encode on . This is particularly meant for the purpose of sending json data to qcubed . js through ajax but can be used for other things as well .