> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cdp.coinbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JsonUtils

> Utility class for JSON operations.

Package: [`com.coinbase.cdp.auth`](/sdks/cdp-sdks-v2/java/com/coinbase/cdp/auth/index)

```java theme={null}
public final class JsonUtils extends Object
```

Utility class for JSON operations.

Provides functionality for sorting JSON object keys recursively, which is required for computing consistent request hashes.

## Method Details

### `sortKeys`

```java theme={null}
public static Map<String,Object> sortKeys(Map<String,Object> map)
```

Recursively sorts all keys in a map alphabetically.

This is required for computing consistent request hashes, as the hash must be the same regardless of the order in which keys were added to the map.

**Parameters:**

`map` (`Map<String,Object>`) - the map to sort

**Returns:**

`Map<String,Object>` - a new map with all keys sorted alphabetically at all levels

### `toJson`

```java theme={null}
public static String toJson(Map<String,Object> map)
```

Converts a map to a JSON string.

**Parameters:**

`map` (`Map<String,Object>`) - the map to convert

**Returns:**

`String` - the JSON string representation

### `fromJson`

```java theme={null}
public static Map<String,Object> fromJson(String json)
```

Parses a JSON string into a map.

**Parameters:**

`json` (`String`) - the JSON string to parse

**Returns:**

`Map<String,Object>` - the parsed map
