V
V
VladislavNekto2019-08-20 09:58:37
Java
VladislavNekto, 2019-08-20 09:58:37

How to add a custom mapper for a type in Gson?

I need to add a custom mapper for a type in gson. It is outdated in the library that I use, so I want to create my own and set it to Gson so as not to modify the library code.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Cheremisin, 2019-08-20
@leahch

Usually so. Does not work? Then to be more specific...

Gson parser = new Gson(); // create json parser
Type type = new TypeToken<Map<String, MyData[]>>(){}.getType(); // create custom type
Map<String, MyData[]> data = parser.fromJson(json, type); // parse data to

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question