# JsonUtil

Artifact: [androidx.media3:media3-transformer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/transformer/JsonUtil.java+class:androidx.media3.transformer.JsonUtil)

*** ** * ** ***

<br />

```
@UnstableApi
class JsonUtil
```

<br />

*** ** * ** ***

Utilities for working with JSON

## Summary

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/reference/org/json/JSONObject.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/JsonUtil#exceptionAsJsonObject(java.lang.Exception)(exception: https://developer.android.com/reference/java/lang/Exception.html?)` Creates a `https://developer.android.com/reference/org/json/JSONObject.html` from the `https://developer.android.com/reference/java/lang/Exception.html`. |
| `java-static https://developer.android.com/reference/org/json/JSONObject.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/JsonUtil#exportResultAsJsonObject(androidx.media3.transformer.ExportResult)(exportResult: https://developer.android.com/reference/kotlin/androidx/media3/transformer/ExportResult!)` Creates a `https://developer.android.com/reference/org/json/JSONObject.html` from the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/ExportResult`. |
| `java-static https://developer.android.com/reference/org/json/JSONObject.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/JsonUtil#getDeviceDetailsAsJsonObject()()` Returns a `https://developer.android.com/reference/org/json/JSONObject.html` containing device specific details from `https://developer.android.com/reference/android/os/Build.html`, including manufacturer, model, SDK version and build fingerprint. |
| `java-static https://developer.android.com/reference/org/json/JSONArray.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/JsonUtil#processedInputsAsJsonArray(com.google.common.collect.ImmutableList<androidx.media3.transformer.ExportResult.ProcessedInput>)( processedInputs: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/kotlin/androidx/media3/transformer/ExportResult.ProcessedInput!>! )` Creates a `https://developer.android.com/reference/org/json/JSONArray.html` from `https://developer.android.com/reference/kotlin/androidx/media3/transformer/ExportResult.ProcessedInput`. |

## Public functions

### exceptionAsJsonObject

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

Creates a `https://developer.android.com/reference/org/json/JSONObject.html` from the `https://developer.android.com/reference/java/lang/Exception.html`.

If the exception is an `https://developer.android.com/reference/kotlin/androidx/media3/transformer/ExportException`, `errorCode` is included.

| Parameters |
|---|---|
| `exception: https://developer.android.com/reference/java/lang/Exception.html?` | The `https://developer.android.com/reference/java/lang/Exception.html`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/org/json/JSONObject.html?` | The `https://developer.android.com/reference/org/json/JSONObject.html` containing the exception details, or `null` if the exception was `null`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/org/json/JSONException.html` | if this method attempts to create a JSON with null key. |

### exportResultAsJsonObject

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

Creates a `https://developer.android.com/reference/org/json/JSONObject.html` from the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/ExportResult`.

| Parameters |
|---|---|
| `exportResult: https://developer.android.com/reference/kotlin/androidx/media3/transformer/ExportResult!` | The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/ExportResult`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/org/json/JSONObject.html!` | The `https://developer.android.com/reference/org/json/JSONObject.html` describing the `exportResult`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/org/json/JSONException.html` | if this method attempts to create a JSON with null key. |

### getDeviceDetailsAsJsonObject

```
java-static fun getDeviceDetailsAsJsonObject(): JSONObject!
```

Returns a `https://developer.android.com/reference/org/json/JSONObject.html` containing device specific details from `https://developer.android.com/reference/android/os/Build.html`, including manufacturer, model, SDK version and build fingerprint.

| Throws |
|---|---|
| `https://developer.android.com/reference/org/json/JSONException.html` |   |

### processedInputsAsJsonArray

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

Creates a `https://developer.android.com/reference/org/json/JSONArray.html` from `https://developer.android.com/reference/kotlin/androidx/media3/transformer/ExportResult.ProcessedInput`.

| Parameters |
|---|---|
| `processedInputs: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/kotlin/androidx/media3/transformer/ExportResult.ProcessedInput!>!` | The list of `https://developer.android.com/reference/kotlin/androidx/media3/transformer/ExportResult.ProcessedInput` instances. |

| Returns |
|---|---|
| `https://developer.android.com/reference/org/json/JSONArray.html!` | A `https://developer.android.com/reference/org/json/JSONArray.html` containing `https://developer.android.com/reference/org/json/JSONObject.html` instances representing the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/ExportResult.ProcessedInput` instances. |

| Throws |
|---|---|
| `https://developer.android.com/reference/org/json/JSONException.html` | if this method attempts to create a JSON with null key. |