Conversion between Json_encode and Json_decode

Source: Internet
Author: User
$query = $this->getpluginlist (); Query statement return value
$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 objects (the data source 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": "2013-08-12 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 ":" 2013-08-11 15:20:55 "," Plugin_detail ":" 0 "," plugin_expired ":" 0 "}] ';
To convert an array:
$arrdata = Json_decode ($json);

foreach ($allplugins as $row)
{
Echo $row->id;
Echo $row->plugin_name;
}

Print:
1
A push
2
213231


Reply to discussion (solution)

What does the landlord want to say ...

I Caishuxueqian please understand.
1, the data transmitted in JSON format, accept the end to convert (Json_decode);
2, the object format to store the send, the receiving end can only be displayed in the object format output.

What does the landlord want to say ...
He's tuition, not asking for doubts.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.