{"id":1426,"date":"2019-04-03T12:56:21","date_gmt":"2019-04-03T07:26:21","guid":{"rendered":"http:\/\/blog.openwebsolutions.in\/?p=1426"},"modified":"2019-04-04T11:38:55","modified_gmt":"2019-04-04T06:08:55","slug":"learn-json-encode-decode","status":"publish","type":"post","link":"https:\/\/openwebsolutions.in\/blog\/learn-json-encode-decode\/","title":{"rendered":"LEARN ABOUT JSON ENCODE AND DECODE IN PHP"},"content":{"rendered":"<p>JSON is basically used when we want to send back data to the client server. JSON ENCODE means if the data type is in array format then it actually turns into JSON OBJECT, and JSON DECODE is vice versa to the JSON encode.<\/p>\n<p>here I can show you a small example of JSON ENCODE<\/p>\n<div id=\"crayon-5c93603b171f0614745325-3\" class=\"crayon-line\"><span class=\"crayon-v\">$data<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-t\">array<\/span><span class=\"crayon-sy\">(<\/span><\/div>\n<div id=\"crayon-5c93603b171f0614745325-4\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-h\">\u00a0\u00a0\u00a0\u00a0<\/span><span class=\"crayon-s\">&#8216;name&#8217;<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-s\">&#8216;anwesha&#8217;<\/span><span class=\"crayon-sy\">,<\/span><\/div>\n<div id=\"crayon-5c93603b171f0614745325-5\" class=\"crayon-line\"><span class=\"crayon-h\">\u00a0\u00a0<\/span><span class=\"crayon-h\">\u00a0\u00a0<\/span><span class=\"crayon-s\">&#8216;gender&#8217;<\/span> <span class=\"crayon-o\">=<\/span><span class=\"crayon-o\">&gt;<\/span> <span class=\"crayon-s\">&#8216;Female&#8217;<\/span><span class=\"crayon-sy\">,<\/span><\/div>\n<div id=\"crayon-5c93603b171f0614745325-7\" class=\"crayon-line\"><span class=\"crayon-h\">\u00a0 &#8216;address&#8217;=&gt;&#8217;agarpara&#8217;<\/span><\/div>\n<div id=\"crayon-5c93603b171f0614745325-8\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-sy\">)<\/span><span class=\"crayon-sy\">;<\/span><\/div>\n<div><span class=\"crayon-v\">$json<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-e\">json_encode<\/span><span class=\"crayon-sy\">(<\/span><span class=\"crayon-v\">$data<\/span><span class=\"crayon-sy\">)<\/span><span class=\"crayon-sy\">;<\/span><\/div>\n<div>this way $data which is array datatype turns into JSON object<\/div>\n<div><\/div>\n<div>here is also one small example of JSON\u00a0 DECODE<\/div>\n<div><\/div>\n<div>$json\u00a0=\u00a0&#8220;{\u00a0&#8216;anwesha&#8217;:\u00a0&#8216;<span class=\"crayon-s\">Female<\/span>&#8216;\u00a0}&#8221;;<br \/>\njson_decode(json);<\/div>\n<div>in this way $json turns into json array.<\/div>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>JSON is basically used when we want to send back data to the client server. JSON ENCODE means if the data type is in array format then it actually turns into JSON OBJECT, and JSON DECODE is vice versa to the JSON encode. here I can show you a small example of JSON ENCODE $data [&hellip;]<\/p>\n","protected":false},"author":42,"featured_media":1510,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[22,5],"tags":[35,107],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>LEARN ABOUT JSON ENCODE AND DECODE IN PHP<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/openwebsolutions.in\/blog\/learn-json-encode-decode\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"LEARN ABOUT JSON ENCODE AND DECODE IN PHP\" \/>\n<meta property=\"og:description\" content=\"JSON is basically used when we want to send back data to the client server. JSON ENCODE means if the data type is in array format then it actually turns into JSON OBJECT, and JSON DECODE is vice versa to the JSON encode. here I can show you a small example of JSON ENCODE $data [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/openwebsolutions.in\/blog\/learn-json-encode-decode\/\" \/>\n<meta property=\"og:site_name\" content=\"Openweb Solutions Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-04-03T07:26:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-04-04T06:08:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/04\/json.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"325\" \/>\n\t<meta property=\"og:image:height\" content=\"155\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/\",\"name\":\"Openweb Solutions Blog\",\"description\":\"Transforming ideas into reality\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/openwebsolutions.in\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/learn-json-encode-decode\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/04\/json.jpeg\",\"width\":325,\"height\":155},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/learn-json-encode-decode\/#webpage\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/learn-json-encode-decode\/\",\"name\":\"LEARN ABOUT JSON ENCODE AND DECODE IN PHP\",\"isPartOf\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/learn-json-encode-decode\/#primaryimage\"},\"datePublished\":\"2019-04-03T07:26:21+00:00\",\"dateModified\":\"2019-04-04T06:08:55+00:00\",\"author\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/da2d8523b509f5b26d3cfb7a53cce72a\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/openwebsolutions.in\/blog\/learn-json-encode-decode\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/da2d8523b509f5b26d3cfb7a53cce72a\",\"name\":\"Anwesha Chakraborty\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/466342b885e1f40a44e6b08fb0055c51?s=96&r=g\",\"caption\":\"Anwesha Chakraborty\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/1426"}],"collection":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/comments?post=1426"}],"version-history":[{"count":4,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/1426\/revisions"}],"predecessor-version":[{"id":1507,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/1426\/revisions\/1507"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media\/1510"}],"wp:attachment":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media?parent=1426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/categories?post=1426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/tags?post=1426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}