Php5.2 and earlier versions do not have the json_decode function solution. When writing code today, we need to use the json_decode function. we found that this function was not integrated in versions earlier than php5.2, but we can implement it through custom functions. Copy code. for example, when writing code today, you need to use the json_decode function. we found that this function was not integrated in php5.2 or earlier versions, but we can implement it through a custom function.
The code is as follows:
Function json_decode2 ($ json)
{
$ Comment = false;
$ Out = '$ x = ';
For ($ I = 0; $ I {
If (! $ Comment)
{
If ($ json [$ I] = '{') | ($ json [$ I] = '[') $ out. = 'Array (';
Else if ($ json [$ I] = '}') | ($ json [$ I] = ']') $ out. = ')';
Else if ($ json [$ I] = ':') $ out. = '=> ';
Else $ out. = $ json [$ I];
}
Else $ out. = $ json [$ I];
If ($ json [$ I] = '"' & $ json [($ i-1)]! = "\") $ Comment =! $ Comment;
}
Eval ($ out .';');
Return $ x;
}
However, Array is returned.
The service_json class is used to return objects.
Bytes. Code such...