Use GSON with Fast Android Networking library -
i'm using https://github.com/amitshekhariitbhu/fast-android-networking in project.
does support gson?
if yes how work it? tried searching in documentation contains information jacksonparserfactory.
i found gsonparserfactory in using below
androidnetworking.setparserfactory(new gsonparserfactory());
but not sure how works get
org.json.jsonobject
you can use gson parse json response java class object
private gson gson; gsonbuilder gsonbuilder = new gsonbuilder(); gson = gsonbuilder.create(); //if response id json array androidnetworking.get("your_url") .build() .getasjsonarray(new jsonarrayrequestlistener() { @override public void onresponse(jsonarray response) { //for json array response list<yourmodel> responsearray = arrays.aslist(gson.fromjson(response, yourmodel[].class)); } @override public void onerror(anerror error) { // handle error } }); //if response json object androidnetworking.post("your_url") .build() .getasjsonobject(new jsonobjectrequestlistener() { @override public void onresponse(jsonobject response) { //for json object response yourmodel responseobject = gson.fromjson(response, yourmodel.class); } @override public void onerror(anerror error) { // handle error } });
Comments
Post a Comment