Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

处理json时候能加一个和HandyJson 一样的 designatedPath 字段吗, 这样更方面取出想要的的json了 #1

Open
SnailLoveSmile opened this issue Sep 8, 2022 · 4 comments

Comments

@SnailLoveSmile
Copy link

No description provided.

@ZClee128
Copy link
Owner

ZClee128 commented Sep 8, 2022

我没用过HandyJSON,能给出具体是怎么样的功能吗

@SnailLoveSmile
Copy link
Author

指定解析路径

HandyJSON支持指定从哪个具体路径开始解析,反序列化到Model。

class Cat: HandyJSON {
var id: Int64!
var name: String!

required init() {}

}

let jsonString = "{"code":200,"msg":"success","data":{"cat":{"id":12345,"name":"Kitty"}}}"

if let cat = Cat.deserialize(from: jsonString, designatedPath: "data.cat") {
print(cat.name)
}
类似这样的功能

@ZClee128
Copy link
Owner

知道了

@SnailLoveSmile
Copy link
Author

嗯嗯,辛苦啦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants