Use Retrofit to parse text from JSON file in local

2019-07-20 05:58发布

I have a JSON text file in /res/raw. After reading its text content, I would like to use Retrofit to parse JSON text to Object. But it seems Retrofit only accept input from file in server.

Is there anyway to reuse Retrofit's JSON parser module in this case?

1条回答
Viruses.
2楼-- · 2019-07-20 06:17

You can configure Gson instance once and then just use it both for local parsing and for Retrofit via RestAdapter.Builder.setConverter(new GsonConverter(customGson)

查看更多
登录 后发表回答