0

I wrote a Java program that accepts a JSON object and send to php. However when I receive the JSON in PHP a broken or incomplete array is returned as shown below.

I am sending this JSON object from java and in java I am able to print the JSON object and it shows well:

{"Description":"now locatio-n","ReportedByFirstname":null,"DateReported":null,"Name":"now","FacilityId":"13692","LocationDescription":"now locatio-n","ReportedByPersonId":null,"ReportedByMobileNumber":null,"StatusId":"22","ReportedByLastname":null,"ReportedByEmail":null,"Id":"957394","PriorityId":"2","LocationLat":"","LocationLong":""}

In PHP I print the value as shown below:

print_r($_POST);

and the results are as follows: PLEASE NOTE THE FIRST ELEMENT DESCRIPTION IS NOT FULLY SHOWN.

Array
(
    [defect] => -n","ReportedByFirstname":null,"DateReported":null,"Name":"now","FacilityId":"13692","LocationDescription":"now locatio-n","ReportedByPersonId":null,"ReportedByMobileNumber":null,"StatusId":"22","ReportedByLastname":null,"ReportedByEmail":null,"Id":"957394","PriorityId":"2","LocationLat":"","LocationLong":""}
)
RealSkeptic
  • 33,993
  • 7
  • 53
  • 79
  • http://stackoverflow.com/questions/7181534/http-post-using-json-in-java – Cassian Oct 13 '15 at 08:01
  • json is object not array you may need [json_decode](http://php.net/manual/en/function.json-decode.php) – bansi Oct 13 '15 at 08:02
  • Your using is valid. I think you are printing values wrongly!!are you directly printing the json value using php?instead of `print_r($_POST);` try `json_decode($_POST);` – Santhucool Oct 13 '15 at 09:17
  • Thank you for the respond but it gives me this error: json_decode() expects parameter 1 to be string, array given when code when using print_r(json_decode($_POST)); – Thulani Samuel Nkosi Oct 13 '15 at 09:54

0 Answers0