Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Json_decode returning Null and Error 4

I'm getting null when I decode my Json. $contactInfo is a String from Java(Android) pushed via Volley. I did check the string, it is a string.

I have tried the following

1) Make the $contactInfo with one user's contact only

2) Removed spaces

3) Remove special characters like ♡

4) Remove +

The closest solution I can find to reading such [[data,data],[data,data]] is to use json decode. Is there any other way for me to read this into a array or json?

$contactInfo = "[[john qiu, +16266169643], [Vince, +65 5888 8447]]"
$obj = stripslashes($contactInfo);
$obj = json_decode($obj);
echo json_last_error(); 

echo is returning JSON_ERROR_SYNTAX

contactInfo, for some users , there are special characters like "♡"

like image 321
CodeGuru Avatar asked Apr 10 '26 08:04

CodeGuru


1 Answers

The correct JSON format is

$contactInfo = '[["john qiu", 16266169643], ["Vince", 6558888447]]"

You can validate your output, to see if its right on some website like this one for example

like image 116
Pawel Bieszczad Avatar answered Apr 11 '26 22:04

Pawel Bieszczad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!