Read complex JSON in Swift #5440
Answered
by
stefanhuber
stefanhuber
asked this question in
Q&A
-
Hi, I hope somebody can help me, the docs and experimentation didn't get me anywhere... I have a json given from javascript to a ios native plugin method: {
"items": [
{
"id": "123",
"title": "123"
}, {
"id": "456",
"title": "456"
}
]
} @objc func start(_ call: CAPPluginCall) {
let items = call.options["items"] as! [[String:JSValue]]
// prints 123
print(items[0]["id"]!)
// prints nil
print(items[0]["id"]! as? String)
} I would like to have the object values as strings, but there seems to be no way to turn the |
Beta Was this translation helpful? Give feedback.
Answered by
stefanhuber
Feb 17, 2022
Replies: 1 comment
-
Ok it was a problem with the input JSON, so my fault... Everything works as expected... |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
stefanhuber
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok it was a problem with the input JSON, so my fault... Everything works as expected...