Skip to content

uguraltinsoy/MultiJSON

Repository files navigation

Android MultiJSON

AndroidManifest

 <uses-permission android:name="android.permission.INTERNET"/>

Download

Build Gradle

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}
dependencies {
	implementation 'com.github.uguraltinsoy:MultiJSON:1.0.1'
}

Usage Java - Kotlin

GET DATA

GET String Json with URL

Java

MultiJSON.init().load("<Source Url>").setOnListener(new RequestCreator.JsonObject() {  
  @Override  
  public void Result(JSONObject jsonObject, String json) throws JSONException {  
   
  }  
  
  @Override  
  public void Error(String error) {  
   
  }  
});

Kotlin

MultiJSON.init().load("<Source Url>").setOnListener(object : JsonObject {  
    @Throws(JSONException::class)  
    override fun Result(jsonObject: JSONObject, json: String) {  
         
    }  
  
    override fun Error(error: String) {  
           
    }  
})

GET String Json with Request Property or Header

Java

HashMap<String, String> property = new HashMap<>();  
property.put("X-PCK", "API_KEY");  
property.put("User-Agent", "Mozilla/5.0");  
property.put("Content-type", "application/json");
MultiJSON.init().load("<Source Url>").addProperty(property).setOnListener(new RequestCreator.JsonObject() {  
  @Override  
  public void Result(JSONObject jsonObject, String json) throws JSONException {  
  
  } 
   
  @Override  
  public void Error(String error) {  
  
  }
 });

Kotlin

val property = HashMap<String, String>()  
property["X-PCK"] = "API_KEY"  
property["User-Agent"] = "Mozilla/5.0"  
property["Content-type"] = "application/json"
MultiJSON.init().load("<Source Url>").addProperty(property).setOnListener(object : JsonObject {  
  @Throws(JSONException::class)  
  override fun Result(jsonObject: JSONObject, json: String) {
    
  }  
  
  override fun Error(error: String) {
  
  }  
})

POST DATA

POST to URL

Java

MultiJSON.init().load("<Source Url>").setOnListener(true, new RequestCreator.JsonObject() {  
  @Override  
  public void Result(JSONObject jsonObject, String json) throws JSONException {  
  
  }  
  
  @Override  
  public void Error(String error) {  
  
  }
 });

Kotlin

MultiJSON.init().load("<Source Url>").setOnListener(true, object : JsonObject {  
  @Throws(JSONException::class)  
  override fun Result(jsonObject: JSONObject, json: String) {
    
  }  
  
  override fun Error(error: String) {

  }  
})

Send POST with Request Attribute or Header

Java

HashMap<String, String> property = new HashMap<>();  
property.put("X-PCK", "API_KEY");  
property.put("User-Agent", "Mozilla/5.0");  
property.put("Content-type", "application/json");
MultiJSON.init().load("<Source Url>").addProperty(property).setOnListener(true, new RequestCreator.JsonObject() {  
  @Override  
  public void Result(JSONObject jsonObject, String json) throws JSONException {  
  
  }
  
  @Override  
  public void Error(String error) {  
  
  }
 });

Kotlin

val property = HashMap<String, String>()  
property["X-PCK"] = "API_KEY"  
property["User-Agent"] = "Mozilla/5.0"  
property["Content-type"] = "application/json"
MultiJSON.init().load("<Source Url>").addProperty(property).setOnListener(true, object : JsonObject {  
  @Throws(JSONException::class)  
  override fun Result(jsonObject: JSONObject, json: String) {
    
  }  
  
  override fun Error(error: String) {

  }  
})

Send JSON POST

Java

// JSON OBJECT
JSONObject json = new JSONObject();  
json.put("param", "value");  
json.put("param", "value");  
json.put("param", "value");

OR

// JSON ARRAY
JSONArray json = new JSONArray(); 
json.put("param", "value");  
json.put("param", "value");  
json.put("param", "value");
MultiJSON.init().load("<Source Url>").setOnListener(true, json, new RequestCreator.JsonObject() {  
  @Override  
  public void Result(JSONObject jsonObject, String json) throws JSONException {  
  
  }  
  
  @Override  
  public void Error(String error) {  
  
  }
 });

Kotlin

// JSON OBJECT
val json = JSONObject()  
json.put("param", "value")  
json.put("param", "value")  
json.put("param", "value")

OR

// JSON ARRAY
val jsonArray = JSONArray()
json.put("param", "value")  
json.put("param", "value")  
json.put("param", "value")
MultiJSON.init().load("<Source Url>").setOnListener(true, json, object : JsonObject {  
  @Throws(JSONException::class)  
  override fun Result(jsonObject: JSONObject, json: String) {  
  
  }  
  override fun Error(error: String) {
  
  }  
})

JSON POST with Request Attribute or Header

Java

HashMap<String, String> property = new HashMap<>();  
property.put("X-PCK", "API_KEY");  
property.put("User-Agent", "Mozilla/5.0");  
property.put("Content-type", "application/json");

AND

// JSON OBJECT
JSONObject json = new JSONObject();  
json.put("param", "value");  
json.put("param", "value");  
json.put("param", "value");

OR

// JSON ARRAY
JSONArray json = new JSONArray(); 
json.put("param", "value");  
json.put("param", "value");  
json.put("param", "value");
MultiJSON.init().load("<Source Url>").addProperty(property).setOnListener(true, json, new RequestCreator.JsonObject() {  
  @Override  
  public void Result(JSONObject jsonObject, String json) throws JSONException {  
  
  }  
  
  @Override  
  public void Error(String error) {  
  
  }
 });

Kotlin

val property = HashMap<String, String>()  
property["X-PCK"] = "API_KEY"  
property["User-Agent"] = "Mozilla/5.0"  
property["Content-type"] = "application/json"

AND

// JSON OBJECT
val json = JSONObject()  
json.put("param", "value")  
json.put("param", "value")  
json.put("param", "value")

OR

// JSON ARRAY
val jsonArray = JSONArray()
json.put("param", "value")  
json.put("param", "value")  
json.put("param", "value")
MultiJSON.init().load("<Source Url>").addProperty(property).setOnListener(true, json, object : JsonObject {  
  @Throws(JSONException::class)  
  override fun Result(jsonObject: JSONObject, json: String) {  
  
  }  
  override fun Error(error: String) {
  
  }  
})

Developer By

Uğur Altınsoy

Donate

BTC  : 1N7V3wX4xvGfwgBP1zQrcMSxohKKfiDxyH
ETH  : 0x0df6da87e219fb4854e933f1071ad91d17afa517
XRP  : rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh
DOGE : DKKmSHAa8GhAE5HNjmCXzkXPKTjpybY3mq
DENT : 0x0df6da87e219fb4854e933f1071ad91d17afa517

Social

Twitter Instagram Linkedin Google Play