JSONObjectHelper

open class JSONObjectHelper

This allows other classes (primarily test classes) to register &receive events generated by the sdk.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
open fun addAll(destinationArray: JSONArray, array: JSONArray)
Add all elements from array to destinationArray
Link copied to clipboard
open fun makeJSONObject(key: String, value: Any): JSONObject
Link copied to clipboard
open fun opt(arr: JSONArray, index: Int): Any
Return null if arr doesn't have value at index or the value is null JSONArray.opt(index) return the JSONObject.
open fun opt(obj: JSONObject, key: String): Any
Return null if object doesn't have key or if obj has null for key JSONObject.opt(key) return the JSONObject.
Link copied to clipboard
open fun optString(obj: JSONObject, key: String): String
Return null if obj doesn't have key or if obj has null for key JSONObject.
open fun optString(obj: JSONObject, key: String, fallback: String): String
Return the fallback if obj doesn't have key or if obj has null for key JSONObject.
Link copied to clipboard
Return null if obj doesn't have key or if obj has null for key - and return value as a String[] otherwise
Link copied to clipboard
open fun <T> pluck(jsonArray: JSONArray, key: String): List<T>
Given a JSONArray of JSONObject, return list made of values for key
open fun <T> pluck(jsonObjects: Array<JSONObject>, key: String): List<T>
Given an array of JSONObject, return list made of values for key
Link copied to clipboard
open fun <T> toList(jsonArray: JSONArray): List<T>
Convert JSONArray of T into list of T
Link copied to clipboard
open fun <T> toMap(jsonObject: JSONObject): Map<String, T>
Convert JSONObject into Map of String to T