5 ms·
Modern Ruby Serializers
- cooljacob204 6y agofast_jsonapi appears to be abandoned. Community fork can be found here: https://github.com/jsonapi-serializer/jsonapi-serializer https://github.com/jsonapi-serializer/jsonapi-serializer
- skunkworker 6y agoYup this. It's easy to get confused for someone googling it as they will see the Netflix one and gravitate towards that repo. But in my experience with the fast_jsonapi, It's the only one I've used in Rails where the serializer is faster than the database calls consistently and occasionally sub millisecond.
- save_ferris 6y agoStuff like this frustrates me from a corporate open source stewardship perspective. Companies love to talk about how they support FOSS during recruiting, but they can't even be bothered to formally update the repository with a deprecation notice when they decide it's no longer in their interest to support a project. And in this case, a lot of people rely on this package. I don't necessarily think that companies should be expected to maintain OS packages they write forever, but respecting the community by openly communicating their plans for the project instead of making end users figure it out should be the bare minimum for acceptable stewardship. Just abandoning this project without a heads up is some bush league BS by Netflix.
- ksec 6y agoIs Netflix moving off Ruby and Rails?
- nitrogen 6y agoI wish more examples of serializers would show the resulting Hash or JSON, rather than just the DSL syntax.
- zrail 6y agoIf I were writing an API in Ruby today I would define my output types as Sorbet structs and call `serialize.to_json` on them at render time. I haven't benchmarked it against anything but it seems reasonably fast.
- cooljacob204 6y agoWhile I have heard a lot of good things about Sorbet I would still hesitate to use it with Ruby 3 and it's type language RBS around the corner.
- cguess 6y agoI'm surprised there was no mention of Blueprinter (https://github.com/procore/blueprinter https://github.com/procore/blueprinter), a format-agnostic, maintained serializer that's very obviously a successor to the ActiveModelSerializer that is mentioned. Personally, I don't like fast_jsonapi because it's impossible to retrofit an app that already exists to it. The standard is so specific (and, in my opinion overkill unless you're Netflix) that it's just not the right fit for a lot of APIs.
- syspec 6y agoAgreed. I used fast_jsonapi on a project, and while I liked it, I felt that I had to change my project to work a round it and not the other way around. For my next project, I used `blueprinter`, which seems to be pretty fast in its own right (there was no discernible difference from what I could tell). Overall I i'd like to give fast_jsonapi another try, but only once I see serialization is my bottleneck
- unixhero 6y agoWhat is to serialize? When do I need to do that?
- nitrogen 6y agohttps://en.wikipedia.org/wiki/Serialization https://en.wikipedia.org/wiki/Serialization It's a fancy name for turning internal program data into a stream of bytes (thus the "serial" for "sequential") you can send to another program/computer or save to disk.
- sandstrom 6y agoI really like Graphiti, it’s an excellent serializer that works with JSON API. https://www.graphiti.dev/guides/ https://www.graphiti.dev/guides/