EDITED: I ended up asking the vendor to change the implementation of sending the JSON
I want to parse a JSON string into a Dictionary
using swift
.
The plist key has the following value:
"{runid:\"8090\",status_id:\"5\"}"
and when I convert this into a String
object, it looks like this "\"{runid:\\\"8488\\\",testids:[\"7480769\"]}\""
Code
let data = theString.data(using: .utf8)
let jsonObject = try! JSONSerialization.jsonObject(with: data!, options: .allowFragments)
I have already gone through various posts and am not able to use the conventional solution we use in our daily lives.
Following things I already know:
- The keys are not properly formatted in quotes
- This is ideally not structured in the conventional way for parsing.
NOTE
- Important thing to note is that I will not be able to change the format, because this value is coming from a third party vendor.
- Another thing to note is that this string is being successfully parsed by the JAVA team in the company