- The processing transformation of JSON,
- JSON conversion steps,
A) Set the JSON to an empty string first,
b) While loop, Traverse, while (!! $row = Mysql_fetch_array ($query, MYSQL_ASSOC))
c) splicing json, $json. = Json_encode ($row). ', ';
D) minus the last comma, $json = substr ($json, 0,-1);
e) Echo,json. can.
- Guess, in CI, the echo of the controller can be implemented without the view of the JSON call. Pending Code Validation
- One of the previous JSON combinations of the construction process, the testability code for
First, Print_r prints the array,
View the page source code,
For the first time, the point equals Jsonencode after the code is
Each one is an object, but each end has no comma, it needs a comma, and then constructs the $json, the previous step, $json. = Json_encode ($row);
After that, this step is, $json. = Json_encode ($row). “,”;
One more comma,
Final treatment,
$json = substr ($json, 0,-1);
Finally, the JSON of the array structure needs to be preceded by the [] symbol
The subsequent call, which can be used in the URL,
CI notes, using JSON