Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Which way is better to handle JSON with Crystal
Search
Takuya Arita
August 01, 2015
Programming
1.1k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Which way is better to handle JSON with Crystal
Takuya Arita
August 01, 2015
More Decks by Takuya Arita
See All by Takuya Arita
Hosted Redash の EOL と移行ツール redash-migrate / You should know about Hosted Redash EOL and redash-migrate
ariarijp
0
3.4k
Redash で踏み出す BI 導入はじめの一歩 / DataEngineeringStudy Redash
ariarijp
1
2.8k
Redash のいま / Redash in 2021
ariarijp
2
1.2k
Redash 導入・運用を4年ぐらいやって変わったこと・変わらなかったこと / Changed and unchanged things with Redash and me
ariarijp
0
1.4k
5年前の自分に伝えたい広告 API 周辺の歩き方 / SOT Tech Night vol.1
ariarijp
1
550
使われていない、を知る / How do we know unused things in the real world?
ariarijp
0
490
MULTI_ORG について / What is MULTI_ORG in Redash
ariarijp
1
3.9k
あらためて振り返る Redash の使いどころ / Why I strongly recommend Redash
ariarijp
2
1.3k
PHP Data Structures
ariarijp
1
580
Other Decks in Programming
See All in Programming
XHTMLが残したもの
yosuke_furukawa
PRO
2
710
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
180
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
140
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
3
530
ハーネス設計入門 〜プロンプト、コンテキストの次〜
kinopeee
56
38k
Foundry Localでエージェント開発
seosoft
0
180
【DroidKaigi 2026】「アクセシビリティを利用するとき、 アクセシビリティもまたこちらを利用している」 〜マルウェアによる攻撃と防衛について〜
halunoyo
0
450
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
110
Laravelのアプリケーションをどこにデプロイするか #ツナギメオフライン.9
akase244
0
120
App Intentsのビルドプロセスを支える技術
kntkymt
0
290
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
410
Jetpack Compose メカニズム
skydoves
0
140
Featured
See All Featured
What does AI have to do with Human Rights?
axbom
PRO
1
2.4k
KATA
mclloyd
PRO
35
15k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
830
Marketing to machines
jonoalderson
1
5.8k
How to train your dragon (web standard)
notwaldorf
97
6.8k
Paper Plane
katiecoart
PRO
3
53k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
It's Worth the Effort
3n
188
29k
How to Talk to Developers About Accessibility
jct
2
540
A designer walks into a library…
pauljervisheath
211
25k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7k
Transcript
Which way is better to handle JSON with Crystal @ariarijp
w !BSJBSJKQ 5BLVZB"SJUB w $PDPMBCMF *OD w 4PGUXBSF&OHJOFFS "CPVUNF
Today’s Lightning talk
The idea from ཬ.rb 1st anniversary https://nishinipporirb.doorkeeper.jp/events/25958
None
I talked about my first Crystal program
Parse JSON using Crystal
None
I compared Ruby and Crystal
None
Crystal is awesome. But I don’t like Java like type
casting
Next morning
None
@asterite commented on my repository (Amazingly, @asterite read Japanese!) https://github.com/ariarijp/ninirb-1st-anniversary-lt-crystal/commit/2d0062c4a1dc4cabaeb6884591c1771d768c0ce8
As a result
The legacy way require "http/client" require "json" place = ARGV[0]
url = "http://api.openweathermap.org/data/2.5/weather?q=#{place}" resp = HTTP::Client.get(url) weather = JSON.parse(resp.body) pp (((weather as Hash)["weather"] as Array)[0] as Hash)["main"] puts "-" * 80 pp weather
Crystal way require "http/client" require "json" class WeatherResponse json_mapping({ weather:
Array(Weather), }) class Weather json_mapping({ id: Int32, main: String, description: String, icon: String, }) end end place = ARGV[0] url = "http://api.openweathermap.org/data/2.5/weather?q=#{place}" resp = HTTP::Client.get(url) puts "-" * 80 weather_resp = WeatherResponse.from_json(resp.body) pp weather_resp pp weather_resp.weather[0].main
Use JSON Mapping!
Crystal is Awesome!
end