App That Uses Maps API

What is being printed to the console now?

I/Corona  (21742): {
I/Corona  (21742):   “bytesEstimated”:-1,
I/Corona  (21742):   “bytesTransferred”:148,
I/Corona  (21742):   “name”:“networkRequest”,
I/Corona  (21742):   “phase”:“ended”,
I/Corona  (21742):   “requestId”:"<type ‘userdata’ is not supported by JSON.>",
I/Corona  (21742):   “response”:"{“1”:{“barberid”:2,“distance”:0.0043117895569319},“2”:{“barberid”:5,“distance”:0.0043117895569319},“3”:{“barberid”:6,“distance”:0.0043117895569319}}",
I/Corona  (21742):   “responseHeaders”:{
I/Corona  (21742):     “Connection”:“Keep-Alive”,
I/Corona  (21742):     “Content-Type”:“text/html”,
I/Corona  (21742):     “X-Android-Response-Source”:“NETWORK 200”,
I/Corona  (21742):     “Date”:“Tue, 19 Jul 2016 19:27:51 GMT”,
I/Corona  (21742):     “X-Android-Sent-Millis”:“1468956470146”,
I/Corona  (21742):     “X-Android-Received-Millis”:“1468956470219”,
I/Corona  (21742):     “X-Android-Selected-Transport”:“http/1.1”,
I/Corona  (21742):     “Keep-Alive”:“timeout=5, max=100”,
I/Corona  (21742):     “X-Powered-By”:“PHP/5.5.9-1ubuntu4.14”,
I/Corona  (21742):     “Vary”:“Accept-Encoding”,
I/Corona  (21742):     “HTTP-STATUS-LINE”:“HTTP/1.1 200 OK”,
I/Corona  (21742):     “Server”:“Apache/2.4.7 (Ubuntu)”
I/Corona  (21742):   },
I/Corona  (21742):   “responseType”:“text”,
I/Corona  (21742):   “status”:200,
I/Corona  (21742):   “url”:"http://107.170.34.199/barber_search_script.php?currentLat=25.9907928&currentLng=-80.3568651",
I/Corona  (21742):   “isError”:false
I/Corona  (21742): }
I/Corona  (21742): Success!
I/Corona  (21742): {“1”:{“barberid”:2,“distance”:0.0043117895569319},“2”:{“barberid”:5,“distance”:0.0043117895569319},“3”:{“barberid”:6,“distance”:0.0043117895569319}}

networkListener:

local function networkListener( event ) print( json.prettify( event ) ) if ( event.isError ) then print( "Network error: ", event.response ) else print ( "Success!" ) myTable = json.decode(event.response) print(event.response) print(myTable[1].barberid) end end

I even tried changing the php script to fetch_row instead of fetch_assoc, still nothing. (right now its back to fetc_assoc)

The keys are strings, not numbers which is weird. But it id convert the id and distance to numbers correctly.

Yeah youre right. Funny thing is i thought about that before and tried changing the way the loop stored the rows in the array in php but it didnt work as i expected it to. I now did print(myTable[“1”].barberid and it worked. I don’t understand why the index is stored as a string when i defined the counter to be 1, weird.

Do you think it has anything to do with the way json encodes the table? I tried converting the counter to an int (even though there shouldn’t be the need to since its supposedly already an int), and still couldnt change the key to be a number. I also tried making a variable called index to use when looping through the table, and it didnt work how i expected it to.

Would be something like this (no loop yet):

local index = 1 tostring(index) print(myTable[index].barberid)

More like:

local index = 1 print(myTable[tostring(index)].barberid)

Nice, your way worked. Thanks for all the help Rob!