Create JSON with json_encode and json_decode using PHP

Create JSON with json_encode and json_decode using PHP

In this Post We Will Explain About is Create JSON with json_encode and json_decode using PHP With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Converting Object to JSON and JSON to Object in PHPExample

In this post we will show you Best way to implement Using PHP’s JSON encode and decode functions, hear for PHP and JSON – json_encode and json_decodewith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Below is simple as well as a small example of PHP function json_encode() & json_decode().

Step 1: Create Json using PHP

 array(array("cname" => "Dhameliya Mayur", "salary" => "180000")), "work_post" => array(array("company_name" => "live24u", "role" => "Seniour Manager", "person" => "91")));
$live_json_encode = json_encode($json_edata);
echo $live_json_encode."
"; ?>

Step 2 : Decode the JSON : using json_decode() functions

 array(array("cname" => "Dhameliya Mayur", "salary" => "180000")), "work_post" => array(array("company_name" => "live24u", "role" => "Seniour Manager", "person" => "91")));
$live_json_encode = json_encode($json_edata);
echo $live_json_encode."
"; $obj = json_decode($live_json_encode); foreach($obj->client_details as $udetails){ echo $udetails->cname; echo "
"; echo $udetails->salary; echo "
"; } foreach($obj->work_post as $wdetails){ echo $wdetails->company_name; echo "
"; echo $wdetails->salary; echo "
"; } ?>

Example

I hope you have Got What is php – Convert Object of class stdClass to JSON Object And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Leave a Comment