我的班級是這樣的:GSON定製反序列化邏輯
class Foo {
public String duration;
public String height;
}
我的JSON數據看起來像
{"duration":"12200000", "height":"162"}
現在我想通過反序列化
Foo foo = gson.fromJson(jsonStr, Foo.class);
因此, foo.duration是「20分鐘」(分鐘數), foo.height是「162cm」
這可能使用Gson嗎?
謝謝!
「反序列化」下的含義是什麼? –
我的意思是,Foo foo = gson.fromJson(...) – smilingcoder