Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
zainfikrih authored Oct 21, 2019
1 parent aa1e457 commit d587648
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d587648

Please sign in to comment.