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
JJUG CCC 懇親会LT用資料
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
pawn-4-git
May 18, 2019
Programming
130
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
JJUG CCC 懇親会LT用資料
pawn-4-git
May 18, 2019
More Decks by pawn-4-git
See All by pawn-4-git
JJUG CCC 2018 fall LT
pawn4sd
0
93
Other Decks in Programming
See All in Programming
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
800
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
150
気持ちぃ〜角丸 Squircle
ryu1013
0
320
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
17k
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
280
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
820
AmebaブログはKMPから卒業します
kmars0605
0
210
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
400
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
120
dotNET_vulnclicker_intro.pdf
deka_morita
0
150
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
850
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
371
20k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
940
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
Navigating Weather and Climate Data
rabernat
0
560
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
850
A Modern Web Designer's Workflow
chriscoyier
699
190k
Designing Experiences People Love
moore
143
24k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Darren the Foodie - Storyboard
khoart
PRO
4
4k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
930
Transcript
JSON Map ⇒ 変換の罠 2019.5.18 JJUG CCC LT 蓬莱寿成
自己紹介 • 名前 蓬莱寿成 • 都内の企業で SE をして 8 年目 •
普段は Java を使った Web アプリケーション開発 • Twitter @pawn_4_t • 個人のブログ https://whiletruedotcom.wordpress.com/
自己紹介
自己紹介
自己紹介
本日の内容 • JSON から Map への変換 バージョン Java8 JSONIC のライブラリを使用
問)下のコードの実行結果はどうなるでしょう
問)下のコードの実行結果はどうなるでしょう ClassCastException
問)下のコードの実行結果はどうなるでしょう ClassCastException ClassCastException: java.math.BigDecimal cannot be cast to java.lang.String
問)下のコードの実行結果はどうなるでしょう ClassCastException ClassCastException: • java.math.BigDecimal cannot be cast to java.lang.String
(・・・ BigDecimal ?どこにも使ってないのに?)
解析 • クラスファイルのデコンパイルをしてみる
解析 • クラスファイルのデコンパイルをしてみる ???
解析 • クラスファイルのデコンパイルをしてみる 型の定義がなくなる!!
解析 • クラスファイルのデコンパイルをしてみる Key も Value も型は固定ではない!
解析 • クラスファイルのデコンパイルをしてみる 変換前の文字列の 1234 が”で囲まれてないので数値扱い ⇒Value の型が BigDecimal になる
解析 • クラスファイルのデコンパイルをしてみる BigDecimal の変数を String に変換しようとする ⇒ 例外発生
テストで見つからなかった原因は? API
参考までに • Map<String,Integer> のデコンパイルをしてみる
まとめ • Map の型の定義はコンパイル後は宣言の部分から消える (その後の変数が使用される場所に反映される) • JSON 使いやすいが変換ミスが原因のわかりにくいバグ を生む(そもそも専用の POJO
に変えるべき) • ソース見てもわからなかったらデコンパイルかけてみる