I am trying to parse a JSONArray but unable to do so. I am getting Null as reply
MY JSONArray:
["{\"mapurl\":\"http:\\\/\\\/maps.google.com\\\/maps?q=17.XXXXXXXX,78.xxxxxxx\",\"caller\":\"+91xxxxxxxxx\",\"id\":1,\"reciever\":\"+91xxxxxxxx\",\"timpestamp\":\"3\"}","{\"mapurl\":\"http:\\\/\\\/maps.google.com\\\/maps?q=17.xxxxxxx,78.xxxxxxx\",\"caller\":\"+91xxxxxxxxxx\",\"id\":2,\"reciever\":\"+91xxxxxxxxxx\",\"timpestamp\":\"3\"}"]
I am passing this JSONArray from Android as a GET request in the parameter "add"
my PHP CODE:
<?php
if (isset($_GET['add'])) {
$jsonData = $_GET['add'];
$phpArray = json_decode($jsonData);
var_dump($phpArray);
}
else{
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
?>
echo $_GET['add'];at the top of your code?if ($phpArray == null) echo json_last_error_msg();to see the error.[\"{\\\"mapurl\\\":\\\"http:\\\\\\/\\\\\\/maps.google.com\\\\\\/maps?q=17.xxxxx,78.xxxxxx\\\",\\\"caller\\\":\\\"+91XXXXXXX\\\",\\\"id\\\":1,\\\"reciever\\\":\\\"+91XXXXXXX\\\",\\\"timpestamp\\\":\\\"3\\\"}\",\"{\\\"mapurl\\\":\\\"http:\\\\\\/\\\\\\/maps.google.com\\\\\\/maps?q=17.xxxxxx,78.xxxxxx\\\",\\\"caller\\\":\\\"+91xxxxxxxx\\\",\\\"id\\\":2,\\\"reciever\\\":\\\"+91xxxxxxxx\\\",\\\"timpestamp\\\":\\\"3\\\"}\"]NULLthis is the response that i am getting