alibaba / HandyJSON

A handy swift json-object serialization/deserialization library
Other
4.22k stars 615 forks source link

这个字符串为什么解析不出来呢 #458

Open LYluyu opened 2 years ago

LYluyu commented 2 years ago

这个字符串为什么解析不出来呢

class Attachment: NSObject { var type : String? var subType : String? var data: [String:Any]?

}

{\"type\":\"SYSTEM\",\"subType\":\"SYSTEM_TITLE_URL\",\"data\":\"{\\"title\\":\\"View notification\\",\\"msg\\":\\"User100833 ID(100833) viewed your profile, drop a line to see if User100833 needs help.Get $0.1 if you reply to your customer within 1 minute\\",\\"url\\":\\"star://message/messageDetail?businessId=211215095623664950135157010094\\",\\"appAlertFlag\\":true}\"}

viihua commented 2 years ago

iOS 15 NumberFormatter number 转 string 丢失精度问题

find_and_replace("Pods/HandyJSON/Source/BuiltInBasicType.swift", "formatter.maximumFractionDigits = 16", "formatter.maximumFractionDigits = 10")

thickfive commented 1 year ago

这个在 JSON 解析这里就失败了, "data":"{\"title... , 可以看出来 data 字段的内容也是一个 JSON 字符串, 这种嵌套就需要转义, 看起来 \" 已经转义了, 但实际上 \ 也是需要转义的, 正确的格式应该是 "data":"{\\"title...