{"id":870,"date":"2022-08-30T15:08:33","date_gmt":"2022-08-30T15:08:33","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/problem-about-json-decode-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:08:33","modified_gmt":"2022-08-30T15:08:33","slug":"problem-about-json-decode-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-json-decode-collection-of-common-programming-errors\/","title":{"rendered":"problem about json-decode-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6f0bcea014c1cf2db91a8d97c12a977c?s=32&amp;d=identicon&amp;r=PG&amp;f=1\" \/><br \/>\nJ Modi<br \/>\njava spring-mvc extjs4 form-submit json-decode<br \/>\nI am getting following error which submitting my extjs form. Uncaught Ext.Error: You&#8217;re trying to decode an invalid JSON StringPlease find my code below. Below is my js file. Ext.onReady(function() {var simple = Ext.create(&#8216;Ext.form.Panel&#8217;, {frame : true,title : &#8216;Login Form&#8217;,bodyStyle : &#8216;padding:5px 5px 0&#8217;,width : 350,fieldDefaults : {msgTarget : &#8216;side&#8217;,labelWidth : 75},defaultType : &#8216;textfield&#8217;,defaults : {anchor : &#8216;100%&#8217;},items : [{fieldLabel : &#8216;User Name&#8217;,name : &#8216;userName&#8217;,allowBlank : fals<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/700280d88cdd91fe3d58fe0f0beacd39?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ngray<br \/>\nphp json json-decode<br \/>\nI&#8217;m trying to use json_decode to get &#8220;short_name&#8221; from with the &#8220;universities&#8221; section of the code attached at the bottom of this post &#8211; it&#8217;s from Coursera (online course website).I first do:$Course= json_decode(file_get_contents(COURSES_URL), true);Then I have no problem getting the top-level data such as &#8220;id&#8221; by doing:$CourseId = $Course[&#8216;id&#8217;];But when it comes to within the &#8220;universities&#8221; array, I cant access any data, I keep getting &#8220;Undefined index: short_name&#8221; I have tried all sorts, such as:$university= $Course[&#8216;universities&#8217;][&#8216;short_name&#8217;];But I am getting nowhere now&#8230;How d<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3189f1e006358ec6c65481b9605cd0e3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLightness Races in Orbit<br \/>\nphp json type-conversion json-decode<br \/>\nI am converting from JSON to object and from object to array. It does not what I expected, can you explain to me?$json = &#8216;{&#8220;0&#8221; : &#8220;a&#8221;}&#8217;; $obj = json_decode($json); $a = (array) $obj; print_r($a); echo(&#8220;a0:&#8221;.$a[&#8220;0&#8243;].&#8221;<br \/>\n&#8220;);$b = array(&#8220;0&#8221; =&gt; &#8220;b&#8221;); print_r($b); echo(&#8220;b0:&#8221;.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d3a157e0c2502e659a071c4e7eea28c8?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nramesh<br \/>\njavascript jquery jsonp json-decode<br \/>\nI had a JSON string \/ object in my application. {&#8220;list&#8221;: [{&#8220;name&#8221;:&#8221;my Name&#8221;,&#8221;id&#8221;:12,&#8221;type&#8221;:&#8221;car owner&#8221;},{&#8220;name&#8221;:&#8221;my Name2&#8243;,&#8221;id&#8221;:13,&#8221;type&#8221;:&#8221;car owner2&#8243;},{<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c10d488fd81cc7c2430c6b854868c11d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDaniel A. White<br \/>\nphp jquery ajax json json-decode<br \/>\nI have an AJAX script that post data in one of my PHP file:var _lname = $(&#8216;#ptLastName&#8217;).val();var _fname = $(&#8216;#ptFirstName&#8217;).val();var _mname = $(&#8216;#ptMiddleName&#8217;).val(); $.ajax({type: &#8220;POST&#8221;,url: &#8220;..\/.\/CheckPerson.php&#8221;,data: &#8220;{&#8216;lastName&#8217;:'&#8221; + _lname + &#8220;&#8216;,&#8217;firstName&#8217;:'&#8221; + _fname + &#8220;&#8216;,&#8217;middleName&#8217;:'&#8221; + _mname + &#8220;&#8216;}&#8221;,contentType: &#8220;application\/json; charset=utf-8&#8221;,dataType: &#8220;json&#8221;,success: fun<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f394b822c935303424f4c2ac1ad64831?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nFelix Kling<br \/>\nphp json json-decode<br \/>\nI returned an array of JSON data type from javascript to PHP, I used json_decode($data, true) to convert it to an associative array, but when I try to use it using the associative index, I get the error &#8220;Undefined index&#8221; The retu<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a29704944447d84d2efda23cb79f406d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDammy Love<br \/>\nphp json jquery-ajax knockout.js json-decode<br \/>\nHere is my JavaScript codevar student = student || {}; student.viewModel = function () {var self = this;self.courseCode = ko.observable(&#8220;&#8221;);self.courses = ko.observableArray([{ &#8220;code&#8221;: &#8220;MTH101&#8221;, &#8220;title&#8221;: &#8220;General Mathematics I&#8221; },{ &#8220;code&#8221;: &#8220;CHM101&#8221;, &#8220;title&#8221;: &#8220;Introductory Chemistry I&#8221; },{<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/65a73538c2c7f89f70a9a5ce73093d83?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nashutosh<br \/>\nfacebook yii base64 registration json-decode<br \/>\nI am implementing facebook registration in my Yii site.. I setup application. For registration, in one step, we need to decode facebook users data, send by facebook. Facebook provide the code for decoding information. I implement this code, but having error like: &#8221; Fatal error: Call to undefined function base64_url_decode() in C:\\wamp\\www\\cma\\app\\protec<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ced3b920852c06a56efbaa3bae9060c3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ndafunker<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1e037aa722c82abdf479a505a36bf1ed?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nToby Allen<br \/>\nphp json oop class json-decode<br \/>\nHey guys I&#8217;m getting three things right now that I&#8217;m trying to take care of, and hoping you can help. I have and error, a warning, and a notice in my code that I would like to patch up and am hoping that you can help me, errors are as follows.There are the wonderful errorsPHP Warning: Invalid argument supplied for foreach() in php\/libraries\/RotateLatestAssets.class.php on line 35 PHP Notice: Undefined variable: config in php\/libraries\/RotateLatestAssets.class.php on line 18 PHP Notice: Undefined variable: json in php\/libraries\/RotateLatestAssets.class.php on line 31 PHP Notice: Undefined variable: json in php\/libraries\/RotateLatestAssets.class.php on line 32And then there&#8217;s a really really weird one I comment out in my code&#8230;. I&#8217;m thinking gnomes, but who knows&#8230;.Here&#8217;s the class<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2013-11-09 22:50:06. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>J Modi java spring-mvc extjs4 form-submit json-decode I am getting following error which submitting my extjs form. Uncaught Ext.Error: You&#8217;re trying to decode an invalid JSON StringPlease find my code below. Below is my js file. Ext.onReady(function() {var simple = Ext.create(&#8216;Ext.form.Panel&#8217;, {frame : true,title : &#8216;Login Form&#8217;,bodyStyle : &#8216;padding:5px 5px 0&#8217;,width : 350,fieldDefaults : {msgTarget [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-870","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=870"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/870\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}