# 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
public final class JsonUtil
```

<br />

*** ** * ** ***

Utilities for working with JSON

## Summary

| ### Public methods |
|---|---|
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/org/json/JSONObject.html` | `https://developer.android.com/reference/androidx/media3/transformer/JsonUtil#exceptionAsJsonObject(java.lang.Exception)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Exception.html exception)` Creates a `https://developer.android.com/reference/org/json/JSONObject.html` from the `https://developer.android.com/reference/java/lang/Exception.html`. |
| `static https://developer.android.com/reference/org/json/JSONObject.html` | `https://developer.android.com/reference/androidx/media3/transformer/JsonUtil#exportResultAsJsonObject(androidx.media3.transformer.ExportResult)(https://developer.android.com/reference/androidx/media3/transformer/ExportResult exportResult)` Creates a `https://developer.android.com/reference/org/json/JSONObject.html` from the `https://developer.android.com/reference/androidx/media3/transformer/ExportResult`. |
| `static https://developer.android.com/reference/org/json/JSONObject.html` | `https://developer.android.com/reference/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. |
| `static https://developer.android.com/reference/org/json/JSONArray.html` | `https://developer.android.com/reference/androidx/media3/transformer/JsonUtil#processedInputsAsJsonArray(com.google.common.collect.ImmutableList<androidx.media3.transformer.ExportResult.ProcessedInput>)( https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/androidx/media3/transformer/ExportResult.ProcessedInput> processedInputs )` Creates a `https://developer.android.com/reference/org/json/JSONArray.html` from `https://developer.android.com/reference/androidx/media3/transformer/ExportResult.ProcessedInput`. |

## Public methods

### exceptionAsJsonObject

```
public static @Nullable JSONObject exceptionAsJsonObject(@Nullable Exception exception)
```

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/androidx/media3/transformer/ExportException`, `errorCode` is included.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Exception.html exception` | The `https://developer.android.com/reference/java/lang/Exception.html`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable 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

```
public static JSONObject exportResultAsJsonObject(ExportResult exportResult)
```

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

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/ExportResult exportResult` | The `https://developer.android.com/reference/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

```
public static JSONObject 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.

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

### processedInputsAsJsonArray

```
public static JSONArray processedInputsAsJsonArray(
    ImmutableList<ExportResult.ProcessedInput> processedInputs
)
```

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

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