From d587648fb0cf1b1e3e31a396b0cbc169fbbafef1 Mon Sep 17 00:00:00 2001 From: Zain Fikri Hanastyono Date: Mon, 21 Oct 2019 15:47:25 +0700 Subject: [PATCH] Update README.md --- README.md | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8427ead..b364870 100644 --- a/README.md +++ b/README.md @@ -34,17 +34,53 @@ For more information, see [Where do I place the 'assets' folder in Android Studi Get JSON as a string: ```java - String jsonString = JSONLoader.with(getApplicationContext()).fileName("filename.json").get(); +JSONLoader.with(getApplicationContext()) + .fileName("filename.json") + .get(new StringLoaderListener() { + @Override + public void onResponse(String response) { + // response as String + } + + @Override + public void onFailure(IOException error) { + // error + } + }); ``` Get JSON as JSON Object: ```java - JSONObject jsonObject = JSONLoader.with(getApplicationContext()).fileName("filename.json").getAsJSONObject(); +JSONLoader.with(getApplicationContext()) + .fileName("filename.json") + .getAsJSONObject(new JSONObjectLoaderListener() { + @Override + public void onResponse(JSONObject response) { + // response as JSONObject + } + + @Override + public void onFailure(Exception error) { + // error + } + }); ``` Get JSON as JSON Array: ```java - JSONArray jsonArray = JSONLoader.with(getApplicationContext()).fileName("filename.json").getAsJSONArray(); +JSONLoader.with(getApplicationContext()) + .fileName("filename.json") + .getAsJSONArray(new JSONArrayLoaderListener() { + @Override + public void onResponse(JSONArray response) { + // response ad JSONArray + } + + @Override + public void onFailure(Exception error) { + // error + } + }); ``` For some examples, see the sample App.