Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
JSON serializers and Alba
Search
Masafumi Okura
July 22, 2020
Programming
0
710
JSON serializers and Alba
Rubyにおける各種JSONシリアライザの2020年版比較と自作のgemであるAlbaのご紹介です。
Masafumi Okura
July 22, 2020
Tweet
Share
More Decks by Masafumi Okura
See All by Masafumi Okura
Why doesn't Ruby have Boolean class - final version
okuramasafumi
0
330
Reading Rails 1.0 Source Code
okuramasafumi
0
300
RDoc meets YARD
okuramasafumi
4
180
Why doesn't Ruby have Boolean class?
okuramasafumi
0
24
My KaigiEffect at RubyKaigi 2025, part 1
okuramasafumi
1
58
Writing documentation can be fun with plugin system
okuramasafumi
0
210
Alba: Why, How and What's So Interesting
okuramasafumi
0
420
Why did my proposals get rejected?
okuramasafumi
1
750
A suggestion for the future of RDoc
okuramasafumi
1
450
Other Decks in Programming
See All in Programming
Claude Agent SDK を使ってみよう
hyshu
0
1.3k
なぜGoのジェネリクスはこの形なのか? - Featherweight Goが明かす設計の核心
qualiarts
0
200
NixOS + Kubernetesで構築する自宅サーバーのすべて
ichi_h3
0
1.1k
ソフトウェア設計の実践的な考え方
masuda220
PRO
4
620
Domain-centric? Why Hexagonal, Onion, and Clean Architecture Are Answers to the Wrong Question
olivergierke
3
930
Catch Up: Go Style Guide Update
andpad
0
240
コード生成なしでモック処理を実現!ovechkin-dm/mockioで学ぶメタプログラミング
qualiarts
0
210
Introduce Hono CLI
yusukebe
6
3k
CSC305 Lecture 05
javiergs
PRO
0
230
CSC305 Lecture 09
javiergs
PRO
0
300
エンジニアインターン「Treasure」とHonoの2年、そして未来へ / Our Journey with Hono Two Years at Treasure and Beyond
carta_engineering
0
380
アメ車でサンノゼを走ってきたよ!
s_shimotori
0
230
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
115
20k
Being A Developer After 40
akosma
91
590k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
34
2.3k
The World Runs on Bad Software
bkeepers
PRO
72
11k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.2k
Designing Experiences People Love
moore
142
24k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Designing for Performance
lara
610
69k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.7k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Transcript
RubyͷJSONγϦΞϥΠβΛ ൺֱͯ͠Έͨ2020൛ Gotanda.rb#44 2020-07-22 ©େխ࢙
ࣗݾհ • ໊લɿେխ࢙ • ॴଐɿϑϦʔϥϯεʢྺ1ͪΐͬͱɺRubyࣗମ8΄Ͳʣ • ΤσΟλɿNeovimʢVimྺ8΄Ͳʣ • ͖ͳϝιουɿinstance_exec •
झຯɿᘖᘣ☕
ࣗݾհʢଓ͖ʣ • Kaigi on RailsͷνʔϑΦʔΨφΠβʔΛ͍ͯ͠·͢ • CFPࠓ݄·ͰͳͷͰ͢ωλ͕͋Δํͥͻʂ • ʰϚελϦϯάVimʱͷ༁Λ͠·ͨ͠ •
Grow.rbͱEntaku.rbͱ͍͏ίϛϡχςΟΛιϩͰӡӦ͍ͯ͠·͢ • Shibuya.rbͱTama.rbͷڞಉΦʔΨφΠβʔͰ͋Γ·͢
ࠓͷςʔϚɿ API/JSONʹ͍ͭͯ
RubyΛͬͯJSONΛฦ͢ํ๏
JSONγϦΞϥΠβ
ϝδϟʔͲ͜ΖΛൺֱͯ͠Έͨ
JSONγϦΞϥΠβ3ܼʢେௐʣ • ActiveModelSerializersʢҎԼAMSʣ • ελʔ5kɺ • jbuilder • ελʔ3.8kɺRailsͷσϑΥϧτʹؚ·ΕΔɺ •
fast_jsonapi • ελʔ5k
ͦͷଞͷJSONγϦΞϥΠβ • jsonapi-rb • jsonapi-resources • blueprinter • jb •
representable • jsonapi-serializer
AMS • ݹࢀͷJSONγϦΞϥΠβ • Pros • ྺ࢙͕͘ɺWebʹهࣄ͕๛ʹ͋Δ • ͲΜͳJSONεΩʔϚʹରԠՄೳ •
Cons • ΄΅ϝϯς͞Ε͍ͯͳ͍༷ࢠ • ʹ͕͋Δʢಛʹfast_jsonapiͱͷൺֱͰʣ
jbuilder • Railsͷ४ެࣜJSONγϦΞϥΠβ • Pros • RailsͷίΞνʔϜʹϝϯς͞Ε͍ͯΔ҆৺ײ • RailsͰ͏ͳΒґଘؔΛ૿ͣ͞ʹࡁΉ •
Cons • ͍ɺ͔ͳΓ͍ • ه๏ʢDSLʣ͕ಠಛͰशಘ͕େม
fast_jsonapi • Netflix͕ग़ͨ͠JSON:APIಛԽܕͷJSONγϦΞϥΠβ • Pros • ඇৗʹߴ • Cons •
JSON:APIʹ४ڌͨ͠APIʹͨ͑͠ͳ͍ • Netflix͕ϝϯςΛ์غ͠ɺ༗ࢤͷϑΥʔΫ͕ଘࡏ͢Δ͕gemͷ໊લ͕ มΘ͍ͬͯͨΓͯࠞ͠ಱͱ͍ͯ͠Δ
".4 KCVJMEFS GBTU@KTPOBQJ ύϑΥʔϚϯε ͦͦ͜͜ ѱ͍ ඇৗʹྑ͍ ϝϯςφϯε ͞Ε͍ͯͳ͍ ͞Ε͍ͯΔ
͞Ε͍ͯͳ͍ ҙͷ+40/εΩʔ ϚʹରԠ͍ͯ͠Δ ͍Δ ͍Δ ͍ͳ͍
͜͜·Ͱͷ݁
• ߴ • ϝϯς͞Ε͍ͯΔ • ҙͷεΩʔϚͷJSON͕ग़ྗͰ͖ ΔʢJSON:APIܗࣜҎ֎ʹରԠ͠ ͍ͯΔʣ
ͳ͍ʁ
͓Εͷ͔Μ͕͍͖͑ͨ͞ΐ͏ ͷJSONγϦΞϥΠβɺAlba ͷ͝հ Gotanda.rb#44 2020-07-22 ©େխ࢙
• ߴ • ϝϯς͞Ε͍ͯΔ • ҙͷεΩʔϚͷJSON͕ग़ྗͰ͖ ΔʢJSON:APIܗࣜҎ֎ʹରԠ͠ ͍ͯΔʣ
ػೳΛߜΔ
ࢦ͖ͩ͢ͱࢥ͏ͷ
• ΑΓখ͞ͳίΞ • ΑΓগͳ͍DSL • ΑΓগͳ͍ґଘؔ
ΑΓখ͍͞ίΞ • ShrineʢϑΝΠϧΞοϓϩʔυϥΠϒϥϦʣRodaʢܰྔΣϒΞ ϓϦέʔγϣϯϑϨʔϜϫʔΫʣͷΑ͏ͳϓϥάΠϯϕʔεͷߏʹ ಌΕ͍ͯΔ • ࢦ͢ίΞͷResourceϞδϡʔϧΛ100ߦҎԼʹཹΊΔ͜ͱ • ֎෦͔Β֦ுՄೳʹ͍ͨ͠ •
ίΞͷϝϯςΛָʹ͍ͨ͠
ΑΓগͳ͍DSL • attribute, one, many͘Β͍Ͱे͔ͳͱࢥ͍ͬͯΔ • jbuilderͷDSL͕͔ͳΓۤखͱ͍͏ݸਓతͳؾ࣋ͪ • has_manyΛΑ͘ݟ͔͚Δ͚ͲɺRuboCopʹޡղ͞ΕͨΓ͢Δ͋͠· Γ͍͍ΞΠσΞͰͳ͍Α͏ͳ…
ΑΓগͳ͍ґଘؔ • ҙݻʹͳͬͯActiveSupportͷґଘΛՃ͍ͯ͠ͳ͍ • ͦͷ݁Ռͱͯ͠Inflection͕͑ͳͯͭ͘Β͍ • ͦͦʮΦϒδΣΫτΛJSONʹม͢Δʯ͜ͱʹґଘ͕ؔͨ͘ ͞Μඞཁͬͯ͜ͱͳ͍ͷͰɺͱ͍͏ؾ࣋ͪ • ϝϯςָ͕
• ґଘ͕ؔͳ͍gemͷಌΕ
͕࣌ؒ͋ΕιʔείʔυΛ͔ΜͨΜ ʹ͓ݟͤͰ͖Δ͔ͳ