I'm writing a `socket.io` client and I'm having trouble getting the emitted data into any usable format. 

My handler is:

```
socket.on("foriEvent") { data, ack in
    print(data)
}

```

which prints: 

```
[  
   {  
      "foriEvent":{  
         "eventType":"location",
         "state":"moving",
         "latitude":"60.4413407",
         "longitude":"22.2476208",
         "accuracy":"20",
         "ts":1510653600189
      }
   }
]

```

I have a `Struct` that "looks" like that data, and I would like to use something like this where the from object is of type `Data`.

```
let decoder = JSONDecoder()
let foriEvent = try decoder.decode(ForiEvent.self, from: data)

```

Currently I'm using the following to get a Data object, but when I send it to decoder.decode, I get the following error message: 

```
return try JSONSerialization.data(withJSONObject: json, options: JSONSerialization.WritingOptions.prettyPrinted)

```

> 
> 
> ```
> error trying to convert data to JSON typeMismatch(Swift.Dictionary<Swift.String, Any>, 
> Swift.DecodingError.Context(codingPath: [], debugDescription:
> "Expected to decode Dictionary<String, Any> but found an array instead.", underlyingError: nil))
> 
> ```
> 
> 

Could it be my struct? What should it look like? The `Struct` looks like this right now:

```
struct ForiEvent : Codable {
    var eventType: String?
    var state : String?
    var latitude: String?
    var longitude : String?
    var accuracy : String?
    var timeStamp : CLong?
}

struct ForiData : Codable {
    var foriEvent : ForiEvent?
}

```