JsonHelper

open class JsonHelper

The JsonHelper class is a useful tool class to works with "JSON" data format

Author

N7ghtm4r3 - Tecknobit

Constructors

Link copied to clipboard
constructor(jsonSource: T)
Constructor to init JsonHelper tool class
constructor(jsonObjectSource: JSONObject)
Constructor to init JsonHelper tool class
constructor(jsonArraySource: JSONArray)
Constructor to init JsonHelper tool class
constructor(jsonSource: String)
Constructor to init JsonHelper tool class
constructor(jsonObjectSource: JSONObject, jsonArraySource: JSONArray)
Constructor to init JsonHelper tool class

Properties

Link copied to clipboard
open var jsonArraySource: JSONArray
jsonArraySource is instance that memorizes JSONArray to work on
Link copied to clipboard
open var jsonObjectSource: JSONObject
jsonObjectSource is instance that memorizes JSONObject to work on
Link copied to clipboard
NUMERIC_CLASS_CAST_ERROR_VALUE is constant that memorizes default numeric value if ClassCastException has been thrown
Link copied to clipboard
val NUMERIC_DEF_VALUE_IF_MISSED: Int = -1234567890
NUMERIC_DEF_VALUE_IF_MISSED is constant that memorizes default numeric value if the main is missed

Functions

Link copied to clipboard
private open fun <T> assembleList(list: JSONArray): T
Method to assemble a list from JSONArray a generic value
Link copied to clipboard
private open fun <T> autoSearch(json: JSONObject, searchKey: String): T
private open fun <T> autoSearch(json: JSONObject, searchKey: String, defValue: T): T
Method to get from JSONObject a generic value
Link copied to clipboard
private open fun containsKey(json: Any, searchKey: String): Boolean
Method to check if a "JSON" source contains a specific key
Link copied to clipboard
open fun <T> fetchList(searchKey: String): ArrayList<T>
open fun <T, V : ArrayList<out Any>?> fetchList(searchKey: String, defValue: V): ArrayList<T>
open fun <T> fetchList(source: JSONObject, searchKey: String): ArrayList<T>
open fun <T, V : ArrayList<out Any>?> fetchList(source: JSONObject, searchKey: String, defValue: V): ArrayList<T>
Method to get from JSONArray a list of values automatically
Link copied to clipboard
open fun <T> fetchVList(searchKey: String): ArrayList<T>
open fun <T, V : ArrayList<out Any>?> fetchVList(searchKey: String, defValue: V): ArrayList<T>
open fun <T> fetchVList(searchKey: String, listKey: String): ArrayList<T>
open fun <T> fetchVList(json: JSONObject, searchKey: String): ArrayList<T>
open fun <T, V : ArrayList<out Any>?> fetchVList(searchKey: String, listKey: String, defValue: V): ArrayList<T>
open fun <T, V : ArrayList<out Any>?> fetchVList(json: JSONObject, searchKey: String, defValue: V): ArrayList<T>
open fun <T> fetchVList(json: JSONObject, searchKey: String, listKey: String): ArrayList<T>
open fun <T, V : ArrayList<out Any>?> fetchVList(json: JSONObject, searchKey: String, listKey: String, defValue: V): ArrayList<T>
Method to get from JSONObject a list of values automatically
Link copied to clipboard
open fun get(index: Int): Any
open fun get(index: Int, defValue: Any): Any
open fun get(jsonDetails: JSONArray, index: Int): Any
open fun get(jsonDetails: JSONArray, index: Int, defValue: Any): Any
Method to get from JSONArray an object value
open fun get(key: String): Any
open fun get(key: String, defValue: Any): Any
Method to get from JSONObject an object value
open fun get(jsonDetails: JSONObject, key: String): Any
open fun get(jsonDetails: JSONObject, key: String, defValue: Any): Any
Method to get from JSONObject an Object value
Link copied to clipboard
open fun getBigDecimal(index: Int): BigDecimal
open fun getBigDecimal(index: Int, defValue: BigDecimal): BigDecimal
open fun getBigDecimal(jsonDetails: JSONArray, index: Int): BigDecimal
open fun getBigDecimal(jsonDetails: JSONArray, index: Int, defValue: BigDecimal): BigDecimal
Method to get from JSONArray a BigDecimal value
open fun getBigDecimal(key: String, defValue: BigDecimal): BigDecimal
open fun getBigDecimal(jsonDetails: JSONObject, key: String): BigDecimal
open fun getBigDecimal(jsonDetails: JSONObject, key: String, defValue: BigDecimal): BigDecimal
Method to get from JSONObject a BigDecimal value
Link copied to clipboard
open fun getBigInteger(index: Int): BigInteger
open fun getBigInteger(index: Int, defValue: BigInteger): BigInteger
open fun getBigInteger(jsonDetails: JSONArray, index: Int): BigInteger
open fun getBigInteger(jsonDetails: JSONArray, index: Int, defValue: BigInteger): BigInteger
Method to get from JSONArray a BigInteger value
open fun getBigInteger(key: String, defValue: BigInteger): BigInteger
open fun getBigInteger(jsonDetails: JSONObject, key: String): BigInteger
open fun getBigInteger(jsonDetails: JSONObject, key: String, defValue: BigInteger): BigInteger
Method to get from JSONObject a BigInteger value
Link copied to clipboard
open fun getBoolean(index: Int): Boolean
open fun getBoolean(index: Int, defValue: Boolean): Boolean
open fun getBoolean(jsonDetails: JSONArray, index: Int): Boolean
open fun getBoolean(jsonDetails: JSONArray, index: Int, defValue: Boolean): Boolean
Method to get from JSONArray a boolean value
open fun getBoolean(key: String): Boolean
open fun getBoolean(key: String, defValue: Boolean): Boolean
open fun getBoolean(jsonDetails: JSONObject, key: String): Boolean
open fun getBoolean(jsonDetails: JSONObject, key: String, defValue: Boolean): Boolean
Method to get from JSONObject a boolean value
Link copied to clipboard
open fun getDouble(index: Int): Double
open fun getDouble(index: Int, defValue: Double): Double
open fun getDouble(jsonDetails: JSONArray, index: Int): Double
open fun getDouble(jsonDetails: JSONArray, index: Int, defValue: Double): Double
Method to get from JSONArray a double value
open fun getDouble(key: String): Double
open fun getDouble(key: String, defValue: Double): Double
open fun getDouble(jsonDetails: JSONObject, key: String): Double
open fun getDouble(jsonDetails: JSONObject, key: String, defValue: Double): Double
Method to get from JSONObject a double value
Link copied to clipboard
open fun getFloat(index: Int): Float
open fun getFloat(index: Int, defValue: Float): Float
open fun getFloat(jsonDetails: JSONArray, index: Int): Float
open fun getFloat(jsonDetails: JSONArray, index: Int, defValue: Float): Float
Method to get from JSONArray a float value
open fun getFloat(key: String): Float
open fun getFloat(key: String, defValue: Float): Float
open fun getFloat(jsonDetails: JSONObject, key: String): Float
open fun getFloat(jsonDetails: JSONObject, key: String, defValue: Float): Float
Method to get from JSONObject a float value
Link copied to clipboard
open fun getInt(index: Int): Int
open fun getInt(index: Int, defValue: Int): Int
open fun getInt(jsonDetails: JSONArray, index: Int): Int
open fun getInt(jsonDetails: JSONArray, index: Int, defValue: Int): Int
Method to get from JSONArray an int value
open fun getInt(key: String): Int
open fun getInt(key: String, defValue: Int): Int
open fun getInt(jsonDetails: JSONObject, key: String): Int
open fun getInt(jsonDetails: JSONObject, key: String, defValue: Int): Int
Method to get from JSONObject an int value
Link copied to clipboard
open fun getJSONArray(index: Int): JSONArray
open fun getJSONArray(index: Int, defValue: JSONArray): JSONArray
open fun getJSONArray(jsonDetails: JSONArray, index: Int): JSONArray
open fun getJSONArray(jsonDetails: JSONArray, index: Int, defValue: JSONArray): JSONArray
Method to get from JSONArray a list of values
open fun getJSONArray(key: String): JSONArray
open fun getJSONArray(key: String, defValue: JSONArray): JSONArray
open fun getJSONArray(jsonDetails: JSONObject, key: String): JSONArray
open fun getJSONArray(jsonDetails: JSONObject, key: String, defValue: JSONArray): JSONArray
Method to get from JSONObject a list of values
Link copied to clipboard
open fun getJsonHelper(index: Int): JsonHelper
open fun <T> getJsonHelper(index: Int, defValue: T): T
open fun <T> getJsonHelper(key: String, defValue: T): T
open fun <T> getJsonHelper(jsonDetails: JSONArray, index: Int): T
open fun <T> getJsonHelper(jsonDetails: JSONObject, key: String): T
open fun <T> getJsonHelper(jsonDetails: JSONArray, index: Int, defValue: T): T
open fun <T> getJsonHelper(jsonDetails: JSONObject, key: String, defValue: T): T
Method to get from JSON a jsonHelper
Link copied to clipboard
open fun getJSONObject(index: Int): JSONObject
open fun getJSONObject(index: Int, defValue: JSONObject): JSONObject
open fun getJSONObject(jsonDetails: JSONArray, index: Int): JSONObject
open fun getJSONObject(jsonDetails: JSONArray, index: Int, defValue: JSONObject): JSONObject
Method to get from JSONArray a jsonObject
open fun getJSONObject(key: String): JSONObject
open fun getJSONObject(key: String, defValue: JSONObject): JSONObject
open fun getJSONObject(jsonDetails: JSONObject, key: String): JSONObject
open fun getJSONObject(jsonDetails: JSONObject, key: String, defValue: JSONObject): JSONObject
Method to get from JSONObject a jsonObject
Link copied to clipboard
open fun getLong(index: Int): Long
open fun getLong(index: Int, defValue: Long): Long
open fun getLong(jsonDetails: JSONArray, index: Int): Long
open fun getLong(jsonDetails: JSONArray, index: Int, defValue: Long): Long
Method to get from JSONArray a long value
open fun getLong(key: String): Long
open fun getLong(key: String, defValue: Long): Long
open fun getLong(jsonDetails: JSONObject, key: String): Long
open fun getLong(jsonDetails: JSONObject, key: String, defValue: Long): Long
Method to get from JSONObject a long value
Link copied to clipboard
open fun getNumber(index: Int): Number
open fun getNumber(index: Int, defValue: Number): Number
open fun getNumber(jsonDetails: JSONArray, index: Int): Number
open fun getNumber(jsonDetails: JSONArray, index: Int, defValue: Number): Number
Method to get from JSONArray a Number value
open fun getNumber(key: String): Number
open fun getNumber(key: String, defValue: Number): Number
open fun getNumber(jsonDetails: JSONObject, key: String): Number
open fun getNumber(jsonDetails: JSONObject, key: String, defValue: Number): Number
Method to get from JSONObject a Number value
Link copied to clipboard
open fun getString(index: Int): String
open fun getString(index: Int, defValue: String): String
open fun getString(jsonDetails: JSONArray, index: Int): String
Method to get from JSONArray a string value
open fun getString(key: String): String
open fun getString(key: String, defValue: String): String
open fun getString(jsonDetails: JSONObject, key: String): String
open fun getString(jsonDetails: JSONArray, index: Int, defValue: String): String
open fun getString(jsonDetails: JSONObject, key: String, defValue: String): String
Method to get from JSONObject a string value
Link copied to clipboard
open fun <T> setJSONArraySource(jsonArraySource: T)
open fun setJSONArraySource(jsonArraySource: String)
Method to set jsonArraySource instance
Link copied to clipboard
open fun <T> setJSONObjectSource(jsonObjectSource: T)
open fun setJSONObjectSource(jsonObjectSource: String)
Method to set jsonObjectSource instance
Link copied to clipboard
open fun <T> toList(): List<T>
Method to get a list from the jsonArraySource No-any params required
open fun <T> toList(jsonArray: JSONArray): List<T>
Method to get a list from a JSONArray
Link copied to clipboard
open fun toString(): String
Returns a string representation of the object No-any params required