Ruby JSON SERIALIZER 使用场景

ciscolive · 2021年07月22日 · 最后由 zhongsheng 回复于 2021年07月22日 · 470 次阅读

😀 最近在学习 RAILS,发现大家会用到 SERALIZERS。查看官方文档有 ActiveModel::Serialization 已实现 as_json, serailizer_hash 这些功能,也有类似的 GEM 模块,有人指点下为什么需要用到序列化的外部模块吗?

jsonapi-rb is a highly performant and modular JSON:API-only implementation. There's a vibrant community around it that has produced projects such as JSON:API Suite.
fast_jsonapi is a lightning fast JSON:API serializer for Ruby Objects.
jsonapi-resources is a popular resource-focused framework for implementing JSON:API servers.
blueprinter is a fast, declarative, and API spec agnostic serializer that uses composable views to reduce duplication. From your friends at Procore.

有时候需要把对象存在数据库,或者传递参数

需要 登录 后方可回复, 如果你还没有账号请 注册新账号