Is there any way to make PHP
look at a string
as a JSON
?
I have a string
, in a JSON
format of course, and I want to perform actions on it like it was an array. However I don't want to use CJSON::decode
because it takes a long time, Is there a way?
Example for the string:
{"myArray":[{"key1":"val1","key2":"val2","key3":"val3","key4":"val4"},
{"key1":"val2_1","key2":"val2_2","key3":"val2_3","key4":"val2_4"}]}
how about json_decode()
?
I don't think there is faster than that
$string = '{"myArray":[{"key1":"val1","key2":"val2","key3":"val3","key4":"val4"}, {"key1":"val2_1","key2":"val2_2","key3":"val2_3","key4":"val2_4"}]}';
$array = json_decode($string);
Not sure what CJSON::decode is but you have to decode the string so you can use the built in function json_decode($str);