My class is like:
class Foo {
public String duration;
public String height;
}
And my json data looks like
{"duration":"12200000", "height":"162"}
Now I want to deserialize it by
Foo foo = gson.fromJson(jsonStr, Foo.class);
So that,
foo.duration is “20 mins” (number of minutes),
foo.height is “162cm”
Is this possible to do using Gson?
Thanks!
GSON allows creation of custom deserializers/serializers. Try to read here.
Sorry for without an example.
then:
and you should receive result as you wish it to get using
fromJson(...).