Conversion between json_encode and json_decode $ query = $ this-> getPluginList (); // return value of the query statement
$ Ret_plugin_ls = array ();
Foreach ($ query-> result () as $ row) {// object storage
Array_push ($ ret_plugin_ls, $ row );
}
Echo json_encode ($ ret_plugin_ls );
The json_encode data stored as an object (the data source is above) is as follows:
$ Json = '[{"id": "1", "plugin_name": "\ u4e2a \ u63a8", "plugin_describe": "\ u4e2a \ u63a8 \ u63cf \ u8ff0 ", "plugin_provider": "\ u897f \ u6865", "plugin_version": "1.0", "plugin_upload_date": "10:52:26", "plugin_detail": "0", "plugin_expired ": "0" },{ "id": "2", "plugin_name": "213231", "plugin_describe": "12123132", "plugin_provider": "2123321213 ", "plugin_version": "2.0", "plugin_upload_date": "15:20:55", "plugin_detail": "0", "plugin_expired": "0"}] ';
Convert to an array:
$ Arrdata = json_decode ($ json );
Foreach ($ allplugins as $ row)
{
Echo $ row-> id;
Echo $ row-> plugin_name;
}
Print:
1
Push
2
213231
Reply to discussion (solution)
What do you want to say...
Sorry for your learning skills.
1. the receiver needs to convert the data transmitted in json format (json_decode;
2. it is stored and sent as an object, and the receiving end can only output and display in the object format.
What do you want to say...
He is teaching, not asking for help