objective-c - 给一个json体, 根据字段自动生成 一个model类出来 哪个大神知道这是怎么回事
世界只因有你
世界只因有你 2017-04-26 09:03:34
0
7
676

我的意思是 给一个json , 它能给我建个类, 类里面直接匹配好属性.是第三方还是有方法 请大神指教

世界只因有你
世界只因有你

reply all(7)
大家讲道理

The following reference
MJExtension
JSONModel

You can also process Json yourself, convert json into a dictionary, and then use the dictionary to assign values ​​to the properties of the object (traverse the properties of the object and assign values)

淡淡烟草味

As Blake said, first convert Json into a dictionary, and then convert the dictionary into a model. Regarding dictionary conversion, I just wrote an article a few days ago on the underlying principles of how the MJExtension framework converts a dictionary into a model. You can take a look at it. http: //weibo.com/p/1001603912111561547915
Because it is mainly implemented through Runtime, you need to understand the basics of Runtime first

为情所困

https://github.com/EnjoySR/ESJsonFormat-Xcode You can try this

黄舟

To convert json into classes, you need to consider the following two issues
1. How to generate beautiful class types
2. What to do if the shape of each map in the array is different (usually it may mean inheritance

However, the second point is the knowledge implicit in the semantics that is difficult to obtain from a json.

左手右手慢动作

I estimate that most people use third parties

左手右手慢动作

There is an Xcode plug-in that can achieve similar functions, called ESJsonFormat ● GitHub address
It can automatically create classes and attributes based on the content of JSON strings.
For details, please see the DEMO in GitHub.

过去多啦不再A梦

xcode uses ESJsonFormat and IDEA uses GsonFormat.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template