Welcome Guest, Not a member yet? Register   Sign In
JSON Decode
#1

[eluser]nirbhab[/eluser]
Dear All,

I wanna decode a very simple decoding of JSON string.
sample: simplest json format
Code:
$arr = array('nirbhab'=>'barat','ankesh'=>'srivastava');
note:I cann't use json_encode(), not available on my live server.

Need help very urgently

currently i am working with the following url:
http://www.phpclasses.org/browse/package/3512.html

Code:
$arr = array('nirbhab'=>'barat','ankesh'=>'srivastava');
echo FastJSON::encode($arr);
echo FastJSON::decode(FastJSON::encode($arr)); // i want the $arr string back to an array format
#2

[eluser]GSV Sleeper Service[/eluser]
RTFM!
Code:
/**
     * public method
     *
     *    FastJSON::decode(params:String[, useStdClass:Boolean]):*
     *
     * @param    String    valid JSON encoded string
     * @param    Bolean    uses stdClass instead of associative array if params contains objects (default false)
     * @return    *    converted variable or null
     *                is params is not a JSON compatible string.
     * @note    This method works in an optimist way. If JSON string is not valid
     *         the code execution will die using exit.
     *        This is probably not so good but JSON is often used combined with
     *        XMLHttpRequest then I suppose that's better more protection than
     *        just some WARNING.
     *        With every kind of valid JSON string the old error_reporting level
     *        and the old error_handler will be restored.
     *
     * @example
     *        FastJSON::decode('{"param":"value"}'); // associative array
     *        FastJSON::decode('{"param":"value"}', true); // stdClass
     *        FastJSON::decode('["one",two,true,false,null,{},[1,2]]'); // array
     */
#3

[eluser]nirbhab[/eluser]
I tried doing
Code:
FastJSON::decode('{"param":"value"}');
but it gave me FATAL: FastJSON decode method failure [malicious or incorrect JSON string]
#4

[eluser]nirbhab[/eluser]
After a long time, i got something which actually saved my ass.

cheers to CI forum.
PEAR JSON

Have a look over it...this one really nice.
#5

[eluser]mglinski[/eluser]
[quote author="nirbhab" date="1208993227"]After a long time, i got something which actually saved my ass.

cheers to CI forum.
PEAR JSON

Have a look over it...this one really nice.[/quote]
Already found and discussed a while back. Its hella slow, and klunky.
But if it saved your ass, buy it dinner.
-Matt




Theme © iAndrew 2016 - Forum software by © MyBB