@UnstableApi
class JsonUtil


Utilities for working with JSON

Summary

Public functions

java-static JSONObject?

Creates a JSONObject from the Exception.

java-static JSONObject!

Creates a JSONObject from the ExportResult.

java-static JSONObject!

Returns a JSONObject containing device specific details from Build, including manufacturer, model, SDK version and build fingerprint.

java-static JSONArray!

Creates a JSONArray from processed inputs.

Public functions

exceptionAsJsonObject

java-static fun exceptionAsJsonObject(exception: Exception?): JSONObject?

Creates a JSONObject from the Exception.

If the exception is an ExportException, errorCode is included.

Parameters
exception: Exception?

The Exception.

Returns
JSONObject?

The JSONObject containing the exception details, or null if the exception was null.

Throws
org.json.JSONException

if this method attempts to create a JSON with null key.

exportResultAsJsonObject

java-static fun exportResultAsJsonObject(exportResult: ExportResult!): JSONObject!

Creates a JSONObject from the ExportResult.

Parameters
exportResult: ExportResult!

The ExportResult.

Returns
JSONObject!

The JSONObject describing the exportResult.

Throws
org.json.JSONException

if this method attempts to create a JSON with null key.

getDeviceDetailsAsJsonObject

java-static fun getDeviceDetailsAsJsonObject(): JSONObject!

Returns a JSONObject containing device specific details from Build, including manufacturer, model, SDK version and build fingerprint.

processedInputsAsJsonArray

java-static fun processedInputsAsJsonArray(
    processedInputs: ImmutableList<ExportResult.ProcessedInput!>!
): JSONArray!

Creates a JSONArray from processed inputs.

Parameters
processedInputs: ImmutableList<ExportResult.ProcessedInput!>!

The list of ExportResult.ProcessedInput instances.

Returns
JSONArray!

A JSONArray containing JSONObject instances representing the instances.

Throws
org.json.JSONException

if this method attempts to create a JSON with null key.