JSONLoader Library

Additional

Language
Java
Version
1.0.3 (Oct 21, 2019)
Created
Oct 18, 2019
Updated
Oct 23, 2019
Owner
Zain Fikri Hanastyono (zainfikrih)
Contributors
Zain Fikri Hanastyono (zainfikrih)
viveksb007
gifff
adityapp
4
Activity
Badge
Generate
Download
Source code
APK file

Commercial

JSONLoader Library

A simple Android library to open JSON from assets

Download

Grab the latest dependencies through Gradle, add it to your build.gradle with:

allprojects {
 repositories {
  ...
  maven { url 'https://jitpack.io' }
 }
}

and:

dependencies {
    implementation 'com.github.zainfikrih:jsonloader-library:{latest version}'
}

Usage

Put the json file in the assets package on the android project (src / main / assets / filename.json). For more information, see Where do I place the 'assets' folder in Android Studio?

Get JSON as a string:

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:

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:

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.

Contributors

License

Copyright 2019 Zain Fikri H

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0
     
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.