LoginSignup
1
0

More than 1 year has passed since last update.

【Android】GsonでList<Something>をデシリアライズする -> 逆も 超個人的メモ

Last updated at Posted at 2021-07-04

やるたびにググってる
毎度迷子になるの面倒

StringなJsonからList

String somethingsJson = "";
Gson gson = new Gson();
Type collectionType = new TypeToken<Collection<Something>>(){}.getType();
List<Something> somethings = gson.fromJson(somethingsJson, collectionType);

ListからStringなJson

Gson gson = new Gson();
List<Something> somethings = new ArrayList<>();
String somethingsJson = gson.toJson(somethings);
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0