I have one JSON pasted below
{
"name" :
{
"id" : "name",
"label" : "name field",
"disabled" : false,
"display" : true,
"pattern" : "^\\+(?:[0-9] ?){6,14}[0-9]$",
"type" : "text"
},
"age" :
{
"id" : "age",
"label" : "age",
"disabled" : false,
"display" : true,
"pattern" : "^\\+(?:[0-9] ?){6,14}[0-9]$",
"type" : "text"
}
}
I need to pass this JSON string into my method and convert that into a Dictionary of Dictionary type Dictionary<String,Dictionary<String,Any>>
To do this first i tried to validate the JSON string before passing to a method and its always saying invalid json
let jsonData = json.data(using: String.Encoding.utf8)
if JSONSerialization.isValidJSONObject(jsonData) {
print("Valid Json")
} else {
print("InValid Json")
}
any idea why this JSON string always returning invalid json?
I have tried this in playground please check the screenshot enter image description here