JSON response problem

I’m trying to use Google’s geolocation API, my Ajax call successfully returns what appears to be Json.

Handling Ajax.Done is done as follows:

Dim Resp = req.responseText
console.log("Geoloc: ")
console.log(Resp )

Which will show me in the console:

  "location": {
    "lat": 47.510629099999996,
    "lng": 8.5961641
  "accuracy": 1665

Unfortunately, I can’t access the response data fields, console.log(Resp.accuracy) gives me “undefined”, what am I doing wrong?

Are you typing console.log(Resp.accuracy) into the console, or is it in your app?

If in your app, where is it?

It’s in my app, at the ajax done event, just after the console.log(Resp)

I’m really stuck with this, attached you’ll find a small sample project.
You’ll need to add your own Google API key to make it work.

GeoLocJsonTest.appstudio.zip (10.1 KB)

Have you tried
Resp = JSON.parse(req.responseText)
Suggesting this as output you’ve pasted looks like text being output rather than an object

Thanks Michael, I’ve tried Resp = JSON.parse(req.responseText) but it gave me an error:
RangeError: Invalid array length
at _NSBsubCreateArray (basicFunctions.js:1432)…

But your hint got me onto the right track! Since I do most of the coding in basic, I’ve started to look at the javascript the compiler produces:
Resp = JSON.parse = createMultiDimArray(req.responseText);

Without the createMultiDimArray-function, parsing works and I can finally access the values :slight_smile: