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
700
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
230
Reading Rails 1.0 Source Code
okuramasafumi
0
250
RDoc meets YARD
okuramasafumi
4
170
Why doesn't Ruby have Boolean class?
okuramasafumi
0
20
My KaigiEffect at RubyKaigi 2025, part 1
okuramasafumi
1
52
Writing documentation can be fun with plugin system
okuramasafumi
0
210
Alba: Why, How and What's So Interesting
okuramasafumi
0
400
Why did my proposals get rejected?
okuramasafumi
1
730
A suggestion for the future of RDoc
okuramasafumi
1
400
Other Decks in Programming
See All in Programming
速いWebフレームワークを作る
yusukebe
5
1.7k
Ruby Parser progress report 2025
yui_knk
1
450
Processing Gem ベースの、2D レトロゲームエンジンの開発
tokujiros
2
130
デザイナーが Androidエンジニアに 挑戦してみた
874wokiite
0
550
🔨 小さなビルドシステムを作る
momeemt
4
690
AIと私たちの学習の変化を考える - Claude Codeの学習モードを例に
azukiazusa1
10
4.4k
Ruby×iOSアプリ開発 ~共に歩んだエコシステムの物語~
temoki
0
340
複雑なドメインに挑む.pdf
yukisakai1225
5
1.2k
Zendeskのチケットを Amazon Bedrockで 解析した
ryokosuge
3
310
Cache Me If You Can
ryunen344
2
3k
Android 16 × Jetpack Composeで縦書きテキストエディタを作ろう / Vertical Text Editor with Compose on Android 16
cc4966
2
260
print("Hello, World")
eddie
2
530
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
61k
4 Signs Your Business is Dying
shpigford
184
22k
Docker and Python
trallard
46
3.6k
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
Agile that works and the tools we love
rasmusluckow
330
21k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
810
How STYLIGHT went responsive
nonsquared
100
5.8k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
113
20k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
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ͷಌΕ
͕࣌ؒ͋ΕιʔείʔυΛ͔ΜͨΜ ʹ͓ݟͤͰ͖Δ͔ͳ