0

well... i have a problem when i receive the string serialized , is something like

a:1:{i:0;a:13:{s:2:"id";s:7:"1301087";s:6:"NOMBRE";s:12:"XxXxXx XXXXX";s:8:"XXXXXXXX";s:16:"XXXXXXX XXLLXXXX";s:4:"SEXO";s:1:"M";s:8:"XXXXXXXX";s:1:"P";s:7:"XXX_NAC";s:10:"1993-29-13";s:6:"DEPART";s:6:"XXXXXX";s:8:"DISTRITO";s:1:"0";s:4:"ZONA";s:4:"ENCA";s:5:"LOCAL";s:1:"8";s:4:"MESA";s:2:"20";s:5:"ORDEN";s:2:"42";s:6:"CEDULA";s:7:"2692282";}}

in php before i serialize the object i have this

    Array
(
[0] => Array
(
[id] => 1301087
[NOMBRE] => XxXxXx XXXXX
[XXXXXXXX] => P
[SEXO] => M
[XXX_NAC] => 1993-29-13
[DEPART] => XXXXXX
[DISTRITO] => 0
[ZONA] => ENCA
[LOCAL] => 8
[MESA] => 20
[ORDEN] => 42
[CEDULA] => 2692282
)

)

I need to use this array of arrays in my Android application, but I do not know how to retrieve the array to work with it in java PD: the info is sended with the header Content-type: text/plain and i already receive the string i need to convert it to array

regards.

Alvaro
  • 3
  • 3
  • i have an array of array of hashmaps here? – Alvaro Dec 13 '14 at 02:10
  • Use php json_encode() and parse the JSON response in Java as in this example http://stackoverflow.com/questions/5888754/return-json-and-parse-in-java-android – gknicker Dec 13 '14 at 02:58
  • thanks for the answer , i was getting problems of JSON_ERROR_UTF8 With json_enconde but now, i could solve it, parsing the values ​​With utf8_encode – Alvaro Dec 13 '14 at 12:33

1 Answers1

0

Use php json_encode() and parse the JSON response in Java as in this example.

It may also be helpful to set the content-type header on your HTTP response from PHP:

<?PHP
header('Content-Type: application/json');

This last is discussed in more detail here.

Cheers.

Community
  • 1
  • 1
gknicker
  • 5,321
  • 2
  • 19
  • 37