I got this error Syntax error, malformed JSON - php

Im integrating Lightspeed API to my website like POS system. I currently getting the value file_get_contents(), but when Im trying to load it array I gives my the error 4 of json_last_error().
Here is my codes:
$maps_url = "http://cloud-docs.merchantos.com/API/Account/797/Item/?itemID=1";
$maps_json = file_get_contents($maps_url);
//print_r($maps_json);
$maps_array = json_decode(stripslashes($maps_json), true);
echo $data = $maps_array['Item']['systemSku'];
switch (json_last_error()) {
case JSON_ERROR_NONE:
echo ' - No errors';
break;
case JSON_ERROR_DEPTH:
echo ' - Maximum stack depth exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
echo ' - Underflow or the modes mismatch';
break;
case JSON_ERROR_CTRL_CHAR:
echo ' - Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
echo ' - Syntax error, malformed JSON';
break;
case JSON_ERROR_UTF8:
echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
break;
default:
echo ' - Unknown error';
break;
}
json_last_error();

Let me rephrase it then:
The shown URL does not retrieve JSON.
It pulls XML.
Therefore json_decode fails.
Hence there's no usable data in $maps_url.
Which is also why ['Item']['systemSku'] won't work.
(And stripslashes would have made no sense in there anyway).
So, investigate the API you're using. Figure out if there is a JSON variant available. Else throw away your code, and instead use a XML traversal frontend, such as SimpleXML.

As mario has said, $maps_url receives XML.
Check out xml_parse_into_struct for help with XML to array conversion.

Related

php json_decode not working from database (pma)

I am trying to use PHP's json_decode function to get data from the database (phpmyadmin)(the type is set to text) and set it on the page This is the code that i got:
$belangrijkespecs = $productClass->get('belangrijkeSpecs');
$belangrijkespecs = json_decode($belangrijkespecs);
var_dump($belangrijkespecs);
This code outputs
NULL
And when I echo the $productClass->get('belangrijkeSpecs') it outputs:
{"Beeldschermdiagonaal":"10,1 inch (25,7 cm)","Beeldresolutie":"1920 x 1200","Batterijduur":"Tot 12 uur","Gewicht":"525 g","Opslag":"32 GB"}
When I passed this in an online JSON decode website than I get the right array (from the website https://3v4l.org/IHKZZ):
array (
'Beeldschermdiagonaal' => '10,1 inch (25,7 cm)',
'Beeldresolutie' => '1920 x 1200',
'Batterijduur' => 'Tot 12 uur',
'Gewicht' => '525 g',
'Opslag' => '32 GB',
)
When i try json_last_error() with this code:
switch (json_last_error()) {
case JSON_ERROR_NONE:
echo ' - No errors';
break;
case JSON_ERROR_DEPTH:
echo ' - Maximum stack depth exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
echo ' - Underflow or the modes mismatch';
break;
case JSON_ERROR_CTRL_CHAR:
echo ' - Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
echo ' - Syntax error, malformed JSON';
break;
case JSON_ERROR_UTF8:
echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
break;
default:
echo ' - Unknown error';
break;
}
It outputs
- Syntax error, malformed JSON
And if i just use echo json_last_error() it outputs : 4.
i have already tried :
$belangrijkespecs = str_replace("/", "", $belangrijkespecs);
and
$belangrijkespecs = rtrim($belangrijkespecs, "\0");
and
$belangrijkespecs = stripslashes($belangrijkespecs);
the output of var_dump $productClass->get('belangrijkeSpecs') :
string(240) "{"Beeldschermdiagonaal":"10,1 inch (25,7 cm)","Beeldresolutie":"1920 x 1200","Batterijduur":"Tot 12 uur","Gewicht":"525 g","Opslag":"32 GB"
The output of echo addcslashes($belangrijkespecs, '\0..\37!#\177..\377') is:
{"\;\Beeldschermdiagonaal"\;\:"\;\1\0,\1 inch (\2\5,\7 cm)"\;,"\;\Beeldresolutie"\;\:"\;\1\9\2\0 x \1\2\0\0"\;,"\;\Batterijduur"\;\:"\;\Tot \1\2 uur"\;,"\;\Gewicht"\;\:"\;\5\2\5 g"\;,"\;\Opslag"\;\:"\;\3\2 \G\B"\;}
And when i do
$belangrijkespecs = stripslashes($belangrijkespecs); before json_decode it still dosnt work...
Also tried:
$belangrijkespecs = preg_replace('/\\\\/', '', $belangrijkespecs);
But it did not work.
The structure of this 'belangrijkeSpecs' = http://prntscr.com/lvnsbh
I have looked on the internet but the answers that were given did not help me.
So my question is:
How can i get a array from the json encoded string
( $productClass->get('belangrijkeSpecs') )
and I expect an array as a return from the json_decode();
The awnser was that i escaped the string before i did the json_decode. And because i did that there where a lot of backslashes.
Thanks to #Matthijs i found it

Valid JSON Results in PHP json_decode Throwing A Syntax Error

Welp, I see quite a few hits on this, but none seem to answer my question.
I have a REST method that returns this JSON:
This is the exact string in the $result variable, below:
{"people":{"people":{"new_user":{"id":7,"name":"Marvin","lang":"en","read_token":1,"write_token":11,"last_access":"2018-06-17 17:00:02","writeable":true,"surname":"Martian","middle_name":"D","given_name":"Marvin","nickname":"Angry Little Fella","payload":"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDIyLjEuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIKCSBpZD0ic3ZnMjczMzMiIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIiB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgoJIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgMTU2LjggMjE5LjMiCgkgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMTU2LjggMjE5LjM7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPHN0eWxlIHR5cGU9InRleHQvY3NzIj4KCS5zdD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wYXRoIGlkPSJwYXRoMTAzNzIiIGNsYXNzPSJzdDEiIGQ9Ik0tNTc4LjcsNTk3LjdjMC42LDAsMS4yLTEuMSwxLjMtMi41YzAuMS0xLjQtMC40LTIuNi0xLTIuNmMtMC42LDAtMS4yLDEuMS0xLjMsMi41CgkJCUMtNTc5LjgsNTk2LjUtNTc5LjMsNTk3LjYtNTc4LjcsNTk3Ljd6Ii8+Cgk8L2c+CjwvZz4KPC9zdmc+Cg==","payload_type":"image\/svg+xml;base64","associated_login":{"id":11,"name":"Marvin","lang":"en","login_id":"Marvin","write_token":11,"last_access":"2018-06-17 17:00:02","writeable":true,"user_object_id":7,"security_tokens":[11],"password":"6f2T8rK4"}}}}}
Yeah, it's big and fugly, but it is completely valid.
When I feed it to JSONLint, I get a nice green bar and well-formatted JSON:
{
"people": {
"people": {
"new_user": {
"id": 7,
"name": "Marvin",
"lang": "en",
"read_token": 1,
"write_token": 11,
"last_access": "2018-06-17 16:56:49",
"writeable": true,
"surname": "Martian",
"middle_name": "D",
"given_name": "Marvin",
"nickname": "Angry Little Fella",
"payload": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDIyLjEuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIKCSBpZD0ic3ZnMjczMzMiIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIiB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgoJIHhtbG5zPSJod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JCUMtNTcxLjUsNTk2LjQtNTcxLjEsNTk3LjYtNTcwLjQsNTk3LjZ6Ii8+CgkJPHBhdGggaWQ9InBhdGgxMDM2OCIgY2xhc3M9InN0NCIgZD0iTS01NzguNyw1OTcuN2MwLjYsMCwxLjItMS4xLDEuMy0yLjVjMC4xLTEuNC0wLjQtMi42LTEtMi42Yy0wLjYsMC0xLjIsMS4xLTEuMywyLjUKCQkJQy01NzkuOCw1OTYuNS01NzkuMyw1OTcuNi01NzguNyw1OTcuNyIvPgoJCTxwYXRoIGlkPSJwYXRoMTAzNzIiIGNsYXNzPSJzdDEiIGQ9Ik0tNTc4LjcsNTk3LjdjMC42LDAsMS4yLTEuMSwxLjMtMi41YzAuMS0xLjQtMC40LTIuNi0xLTIuNmMtMC42LDAtMS4yLDEuMS0xLjMsMi41CgkJCUMtNTc5LjgsNTk2LjUtNTc5LjMsNTk3LjYtNTc4LjcsNTk3Ljd6Ii8+Cgk8L2c+CjwvZz4KPC9zdmc+Cg==",
"payload_type": "image\/svg+xml;base64",
"associated_login": {
"id": 11,
"name": "Marvin",
"lang": "en",
"login_id": "Marvin",
"write_token": 11,
"last_access": "2018-06-17 16:56:49",
"writeable": true,
"user_object_id": 7,
"security_tokens": [11],
"password": "TuqWG+%y"
}
}
}
}
}
Nevertheless, feeding this JSON to PHP 7.2.1's json_decode() function keeps returning a JSON_ERROR_SYNTAX error (bad syntax).
I think the issue may be with the data in the SVG file, but that is valid Base64 data. It should be fine in JSON.
I tried all the various solutions mentioned in other posts, but still no dice.
Any ideas?
UPDATE: Here's the PHP code that I run it through:
echo('RESULT:<pre>');
var_dump(json_decode($result));
switch (json_last_error()) {
case JSON_ERROR_NONE:
echo ' - No errors';
break;
case JSON_ERROR_DEPTH:
echo ' - Maximum stack depth exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
echo ' - Underflow or the modes mismatch';
break;
case JSON_ERROR_CTRL_CHAR:
echo ' - Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
echo ' - Syntax error, malformed JSON';
break;
case JSON_ERROR_UTF8:
echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
break;
default:
echo ' - Unknown error';
break;
}
echo('</pre>');
That code, in my server/laptop, is what's exposing it.
UPDATE 2: This is the dump from my cURL routine, showing the response:
string(10159) "HTTP/1.1 200 OK
Date: Sun, 17 Jun 2018 17:29:35 GMT
Server: Apache
X-Powered-By: PHP/7.2.1
Content-Length: 10007
Content-Type: application/json
{"people":{"people":{"new_user":{"id":7,"name":"Marvin","lang":"en","read_token":1,"write_token":11,"last_access":"2018-06-17 17:29:35","writeable":true,"surname":"Martian","middle_name":"D","given_name":"Marvin","nickname":"Angry Little Fella","payload":"<REMOVED FOR BREVITY>","payload_type":"image\/svg+xml;base64","associated_login":{"id":11,"name":"Marvin","lang":"en","login_id":"Marvin","write_token":11,"last_access":"2018-06-17 17:29:35","writeable":true,"user_object_id":7,"security_tokens":[11],"password":"1Jq6$oT0"}}}}}"
OK. I wanted to let y'all know what happened. It ain't an answer, but it will be the one I greencheck.
I took off and nuked it from orbit, and now it works.
I have to assume that I did something that sent invisible characters that didn't make it into copy and paste, so the JSONLint never saw them. I'll bet if I had cURLed or wgetted straight from the test harness, it would have borked.
This is a warning to me: Don't get too feisty with the CLI. I'm maybe not as hot at this stuff as I'd like to think.
Thanks for the help, folks.

base64 json_decode issue - php

Fetching BLOB from mysql
$sql = "SELECT data as datajson FROM tablename";
$res=$obj->_executeQuery($sql);
$res=$obj->getAll($res);
$blobdata = $res[0]['datajson'];
My json data from BLOB looks like this
[{"name":"propose","value":"Propose~sample"},
{"name":"expenseamount","value":"Expense Amount~15246"},
{"name":"paymenttype","value":"Payment Type~ Cash"},
{"name":"img0","value":"/9j/4AAQSkZHIjks........61A/3qBo/9k="},
{"name":"img1","value":"NO"}]
Now
{"name":"img0","value":"/9j/4AAQSkZHIjks........61A/3qBo/9k="}
This pair is a base 64 string which is included in my BLOB. And when i did json_decode($blobdata); i am getting null
The exact base64 string can be found in JSFIDDLE
I have added json_last_error(); in my code
switch (json_last_error()) {
case JSON_ERROR_NONE:
echo ' - No errors';
break;
case JSON_ERROR_DEPTH:
echo ' - Maximum stack depth exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
echo ' - Underflow or the modes mismatch';
break;
case JSON_ERROR_CTRL_CHAR:
echo ' - Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
echo ' - Syntax error, malformed JSON';
break;
case JSON_ERROR_UTF8:
echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
break;
default:
echo ' - Unknown error';
break;
}
Which returns - Syntax error, malformed JSON and
json_decode does not work, since this is not a proper json
I want the details other than img0 and img1
1 . Now how do i remove the last two pairs (img0, img1) BEFORE json_decode, so that this becomes valid json.
2 . Or how to convert the base64 string to become proper json
UPDATE
This is how BLOB data is storing in mysql
foreach($_REQUEST as $key=>$value)
{
$raw_data[] = array('name' => $key, 'value' => $value);
}
$json = json_encode($raw_data);
$sql="INSERT INTO tablename (data) VALUES ('$json')";

JSON syntax error occure when jsone_decode in php but json data actually not contain any syntax error

I am trying to get post details using JSON in wordpress. In my plugin following is the json_decode part. But it returns null.
$post_count = intval($instance['post_count']);
$eng_posts= #json_decode(file_get_contents("http://athavaneng.com/?page_id=206861&posts_per_page=".$post_count), true);
switch (json_last_error()) {
case JSON_ERROR_NONE:
echo ' - No errors';
break;
case JSON_ERROR_DEPTH:
echo ' - Maximum stack depth exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
echo ' - Underflow or the modes mismatch';
break;
case JSON_ERROR_CTRL_CHAR:
echo ' - Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
echo ' - Syntax error, malformed JSON';
break;
case JSON_ERROR_UTF8:
echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
break;
default:
echo ' - Unknown error';
break;
}
In the above code I get a JSON_ERROR_SYNTAX error. But actually when I test the returning JSON data of http://athavaneng.com/?page_id=206861 URL on the http://jsonlint.com. It says that "Valid JSON".
Why is that? What is the problem here?
The responding server is sending 3 strange chars before it starts the json output. By doing this:
$var = file_get_contents("http://athavaneng.com/?page_id=206861&posts_per_page=1");
for($i=0; $i<10; $i++) {
echo $var[$i] . " : " . ord($var[$i]) . "<br />";
}
you will get something like this:
ï : 239
» : 187
¿ : 191
{ : 123
" : 34
1 : 49
" : 34
: : 58
{ : 123
" : 34
the first three chars (239,187 and 191) should not been printed by the server. As a workaround you should be able to parse it after stripping the first three chars.
I am able to parse your json with the following code, which beginns reading at character 3:
$var = file_get_contents("http://athavaneng.com/?page_id=206861&posts_per_page=1", false, NULL, 3);
var_export(json_decode($var));

Codeigniter json_decode view as a variable returns NULL

Can't seem to find the solution to this, I want to load json data from a view variable like this
$this->json = $this->load->view('/jsonfiles/page.json','',true);
Outputting
var_dump(json_decode($this->json,true));
= NULL
The View seems to be rendering the .json file incorrectly, for the json_decode to fail. (maybe not incorrectly, but in a different format), Ive already tried to utf8_encode, no luck
JSON Variable within the page.json
[
{
"page" : {
"name" : "PageNameHere",
"date" : true
}
}
]
Or is there an alternative to doing this?
UPDATE: Yes it works when its an actual string in the variable like this
$this->json = '[{"page":{"name":"PageNameHere","date":true}}]';
var_dump(json_decode($this->json,true));
SOLUTION: So I've decided to figure this out one, and by my mistake, I had a "," comma in the last part of my JSON, which wasn't in this thread, I shorten the JSON for topic, but I found it, using this neat error switch, able to find JSON rendering errors
switch (json_last_error()) {
case JSON_ERROR_NONE:
echo ' - No errors';
break;
case JSON_ERROR_DEPTH:
echo ' - Maximum stack depth exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
echo ' - Underflow or the modes mismatch';
break;
case JSON_ERROR_CTRL_CHAR:
echo ' - Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
echo ' - Syntax error, malformed JSON';
break;
case JSON_ERROR_UTF8:
echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
break;
default:
echo ' - Unknown error';
break;
}
My Issue was labeled as "Syntax error, malformed JSON"

Categories