SwiftyJSON icon indicating copy to clipboard operation
SwiftyJSON copied to clipboard

I cant get a string from my json

Open nadia-am opened this issue 7 years ago • 2 comments

screen shot 2018-10-02 at 11 30 04 am 2

i get the notification and wana get the loc_key in data. it gets the data correctly but cant get the loc_key , i dont know what is the problem!

nadia-am avatar Oct 02 '18 08:10 nadia-am

It seems like "data" is String but not Dictionary as was expected. You can use another initializer in this case:

guard let data = userInfo["data"] as? String else {
    return
}
let resultJson = JSON(parseJSON: data)

svallex avatar Nov 28 '18 11:11 svallex

Hi, I think that the solution of @svallex, is perfect for this problem.

SalvoSwift21 avatar Feb 28 '19 14:02 SalvoSwift21