我从HTML代码中提取了JSON字符串。当我将该部分插入JSONLint时,它表示它是有效的JSON。但当我尝试从代码验证它时,它说它无效
从HTML
中提取的字符串 [{"shortid":"456673","url":"https://www.google.com","thumb":"https://www.google.com","imgid":"1:00z0z_5mLB7aZ1QcW"},{"shortid":"456673","url":"https://www.google.com","thumb":"https://www.google.com","imgid":"1:00z0z_5mLB7aZ1QcW"},{"shortid":"456673","url":"https://www.google.com","thumb":"https://www.google.com","imgid":"1:00z0z_5mLB7aZ1QcW"},{"shortid":"456673","url":"https://www.google.com","thumb":"https://www.google.com","imgid":"1:00z0z_5mLB7aZ1QcW"},{"shortid":"456673","url":"https://www.google.com","thumb":"https://www.google.com","imgid":"1:00z0z_5mLB7aZ1QcW"},{"shortid":"456673","url":"https://www.google.com","thumb":"https://www.google.com","imgid":"1:00z0z_5mLB7aZ1QcW"},{"shortid":"456673","url":"https://www.google.com","thumb":"https://www.google.com","imgid":"1:00z0z_5mLB7aZ1QcW"},{"shortid":"456673","url":"https://www.google.com","thumb":"https://www.google.com","imgid":"1:00z0z_5mLB7aZ1QcW"},{"shortid":"456673","url":"https://www.google.com","thumb":"https://www.google.com","imgid":"1:00z0z_5mLB7aZ1QcW"},{"shortid":"456673","url":"https://www.google.com","thumb":"https://www.google.com","imgid":"1:00z0z_5mLB7aZ1QcW"},{"shortid":"456673","url":"https://www.google.com","thumb":"https://www.google.com","imgid":"1:00z0z_5mLB7aZ1QcW"},{"shortid":"456673","url":"https://www.google.com","thumb":"https://www.google.com","imgid":"1:00z0z_5mLB7aZ1QcW"}]
let jsonData = extractedString.data(using: String.Encoding.utf8)
if JSONSerialization.isValidJSONObject(jsonData!) {
print("Valid Json")
} else {
print("InValid Json")
}