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
Journey to Parsing JSON in Android - Lintasarta...
Search
Ahmad Arif Faizin
April 22, 2020
Programming
0
210
Journey to Parsing JSON in Android - Lintasarta Developer Talk Online Series #6
1. Manual Parsing
2. Using GSON
3. Retrofit + GSON
Video :
https://youtu.be/hrfuFt9YUQI
Ahmad Arif Faizin
April 22, 2020
Tweet
Share
More Decks by Ahmad Arif Faizin
See All by Ahmad Arif Faizin
Focus Group Discussion (FGD) Penyempurnaan Kurikulum Program Studi Informatika
arifaizin
0
13
[Indocomtech Event] Intro to AI: Essential Basics and Practical Guide to Get You Started - Coding Camp 2025 powered by DBS Foundation
arifaizin
0
3
BDD 2024 - Automate Dependency Management in a Scalable Way with Gradle Version Catalog
arifaizin
0
130
Tips & Trik Menghabiskan Task dengan Automa
arifaizin
0
11
The Opportunity of a Digital World - Dicoding Career Fair 2023
arifaizin
0
68
Bringing Machine Learning in Android with MediaPipe - DroidJam 2023
arifaizin
2
660
The New Era of Android Development - IDCamp x Kadin 2023
arifaizin
0
55
Building Mobile Apps for People | IDCamp x KADIN 2023
arifaizin
0
57
Adaptive Layout for Any Screen with Jetpack Compose [Dicoding Developer Conference]
arifaizin
1
490
Other Decks in Programming
See All in Programming
Realtime API 入門
riofujimon
0
150
EMになってからチームの成果を最大化するために取り組んだこと/ Maximize team performance as EM
nashiusagi
0
100
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
RubyLSPのマルチバイト文字対応
notfounds
0
120
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
3
700
Quine, Polyglot, 良いコード
qnighy
4
650
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
120
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
200
Functional Event Sourcing using Sekiban
tomohisa
0
100
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
300
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
180
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Being A Developer After 40
akosma
87
590k
Typedesign – Prime Four
hannesfritz
40
2.4k
For a Future-Friendly Web
brad_frost
175
9.4k
Gamification - CAS2011
davidbonilla
80
5k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
130
Transcript
Journey to Parsing JSON in Android Ahmad Arif Faizin Academy
Content Writer Dicoding Indonesia 1
Identify your state 2 Cari requirement pada lowongan pekerjaan dan
pisahkan skill yang sudah dikuasai dan belum dikuasai
Essential Skill 3 Cek di www.dicoding.com/jobs
4 What is Web Services? Suatu layanan yang mengizinkan dua
aplikasi saling terhubung melalui jaringan, sehingga kita dapat mengambil dan mengirim data ke layanan tersebut dengan mudah.
Concept 5
What is JSON? 6 (Javascript Object Notation) merupakan format pertukaran
data yang ringan dan mudah dibaca (dibanding XML). Format ini dapat digunakan di hampir semua bahasa pemrograman.
Try access JSON 7 dicoding.id/cobajson
Whats? 8
9 dicoding.id/jsonformatter
After using JSON Formatter 10
Key-Value 11
JSONArray vs JSONObject 12
How to read JSON in Android?
3 Ways 14 3 2 Manual Parsing 1 Using GSON
Retrofit + GSON
Let’s start the journey… 15
1. Manual Parsing Change one-by-one 16
Basic concept 17
Get all data 18
Final Code Using LoopJ 19 dicoding.id/cobajson1
Final Code Using Volley 20
2. Parsing With GSON Faster way to convert into model
21
GSON library 22 Buka build.gradle(module: app) dan tambahkan kode berikut:
Data Class 23 Tambahkan annotation sesuai JSON
Using GSON 24
Diff 25
Want more? 26
Nested Class 27 Buat model untuk yang paling atas
Using GSON 28
Diff 29
Source code Gson 30 dicoding.id/cobajson2
3. Retrofit + GSON Converter The best way to convert
all responses 31
Retrofit library 32 Buka build.gradle(module: app) dan tambahkan kode berikut:
Setup Retrofit 33 Endpoint : https://reqres.in/api/users?page=1
Get Data with Retrofit 34 Karena data yang didapat sudah
di-parsing, maka tidak perlu fungsi parseJson lagi
Want more? 35
Service Locator Pattern 36 Supaya tidak mengulang-ulang kode, buat satu
class sebagai kode pusat.
Bonus! 37 Plugin RoboPojoGenerator Otomatis membuat class model dari data
json
None
None
Final code 40 dicoding.id/cobajson3
Finish? 41
42 dicoding.id/lpandroid
“Quotations are commonly printed as a means of inspiration and
to invoke philosophical thoughts from the reader. 43
Thanks! Any questions? You can find me at: • Google
: Ahmad Arif Faizin • IG : @arif_faizin • Medium : @arifaizin • Email :
[email protected]
44