Comments (6)
业务类的模型 继承自基类模型,这样情况想调用deserialize转换出来的就全是nil,麻烦大佬指点下
from smartcodable.
是否能像Handlyjson一样,不管是不是继承的model类,都能转换成功呢?
from smartcodable.
只要遵循了SmartCodable,就可以解析的。 不过继承的支持力度不够。 系统的Codable需要子类中重写init(decoder:)方法,并调用super.init(decoder). 详细见readme中的suggest模块的问答。
综合: 不建议使用继承来处理数据解析。 有任何问题可以加QQ群(readme最下面有QQ群截图)
from smartcodable.
原项目中基本都是继承自基类的,您意思是子类模型也要再次继承SmartCodable 就能解析么?
from smartcodable.
继承的实现比较麻烦,我在 继承 中有说明。
建议使用协议替代继承。 将公共的一些属性声明到一个协议中, 各个Model继承该协议,自然带有了公共的属性。
from smartcodable.
好的👌🏻,感谢大佬解惑;
from smartcodable.
Related Issues (20)
- 如何将[String:Any] 转换为[String:SmartAny] HOT 4
- 兼容类String型时 int值为1时解析不出来 HOT 1
- 能否增加自定义转换规则 HOT 4
- 字符串的Model化相关问题 HOT 3
- 枚举类型不匹配的时候没有使用默认值 HOT 5
- AnyHashable HOT 3
- 局部的值解析策略支持SmartDataTransformer HOT 7
- 为啥不支持继承? HOT 4
- 像HandyJSON一样支持已有模型的update? HOT 7
- 能提供具体的使用案例和文档么,类似MJExtension那样的 HOT 1
- 建议完善的单元测试 HOT 5
- 使用SmartAny遇到类型转化错误 HOT 5
- Int32等接收,转化不了String类型的int值 HOT 2
- 日志错误打印 HOT 9
- 可以支持一个类或者结构体中添加这个字典来接受后台的数据吗 HOT 2
- 如何关闭调试过程中的配型不匹配报错 HOT 1
- 请问是否支持忽略key的大小写 HOT 4
- 使用属性包装器的属性可以兼容一下吗 HOT 3
- 可以添加下对visionOS的支持吗 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smartcodable.