Use Retrofit to parse text from JSON file in local

感情迁移 提交于 2020-01-04 06:17:09

问题


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:


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)



来源:https://stackoverflow.com/questions/26922591/use-retrofit-to-parse-text-from-json-file-in-local

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!