-4

I have a dictionary assigned to a variable restaurant from this API.

API Call

I am trying to assign.

let restaurantLat = restaurants[indexPath.row]["geometry"]!["location"]!!["lat"] as? String

This is showing an error:

type any has subscript members.

Alistra
  • 5,177
  • 2
  • 30
  • 42
  • 1
    Split it up in several lines of code to see were it fails. `lat` is not a String btw. – shallowThought Apr 12 '17 at 19:50
  • 1
    Possible duplicate of [Correctly Parsing JSON in Swift 3](http://stackoverflow.com/questions/39423367/correctly-parsing-json-in-swift-3) – vadian Apr 15 '17 at 08:49
  • When you show errors, show them correctly, as you got them from the compiler. I bet $100 that you didn't get the error that you claim you got ("type any has subscript members"). Actually I bet you got an error message that is the exact opposite of what you say. – gnasher729 Apr 15 '17 at 18:16

1 Answers1

0

Access json output data as below:

let restaurantLat = restaurants["results"][indexPath.row]["geometry"]!["location"]!!["lat"] as? String

Because results key contain list of array.

Sakir Sherasiya
  • 1,562
  • 1
  • 17
  • 31