# GCKJSONUtils Class

[Class Methods](https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_j_s_o_n_utils#pub-static-methods) GCKJSONUtils Class Reference

## Overview

Utility methods for working with JSON data.

Inherits NSObject.

|---|---|
| ## Class Method Summary ||
| (nullable id) | + [parseJSON:](https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_j_s_o_n_utils#a8762d8d1a23b97c3d456dfa3bb981913) |
|   | Parses a JSON string into an object. [More...](https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_j_s_o_n_utils#a8762d8d1a23b97c3d456dfa3bb981913) |
|   ||
| (nullable id) | + [parseJSON:error:](https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_j_s_o_n_utils#a264eda897ce3f8df4bbb6191a763d814) |
|   | Parses a JSON string into an object. [More...](https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_j_s_o_n_utils#a264eda897ce3f8df4bbb6191a763d814) |
|   ||
| (NSString \*) | + [writeJSON:](https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_j_s_o_n_utils#ad329d350c0a2035c39d5ec7394f8b94d) |
|   | Writes an object hierarchy of data to a JSON string. [More...](https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_j_s_o_n_utils#ad329d350c0a2035c39d5ec7394f8b94d) |
|   ||
| (BOOL) | + [isJSONString:equivalentTo:](https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_j_s_o_n_utils#a2f6308cd0106982730c795103d1db058) |
|   | Tests if two JSON strings are equivalent. [More...](https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_j_s_o_n_utils#a2f6308cd0106982730c795103d1db058) |
|   ||
| (BOOL) | + [isJSONObject:equivalentTo:](https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_j_s_o_n_utils#aac1932e69f8e470853261dc82c079e41) |
|   | Tests if two JSON objects are equivalent. [More...](https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_j_s_o_n_utils#aac1932e69f8e470853261dc82c079e41) |
|   ||

## Method Detail

|---|---|---|---|---|
| + (nullable id) parseJSON: |   | (NSString \*) | *json* |   |

Parses a JSON string into an object.

Parameters
:

    |---|---|
    | json | The JSON string to parse. |


Returns
:   The root object of the object hierarchy that represents the data (either an [**NSArray**](https://goo.gl/q3tY5n) or an [**NSDictionary**](https://goo.gl/0kFoNp)), or `nil` if the parsing failed.

|---|---|---|---|
| + (nullable id) [parseJSON:](https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_j_s_o_n_utils#a8762d8d1a23b97c3d456dfa3bb981913) |   | (NSString \*) | *json* |
| error: |   | (NSError \*\*) | *error* |
|   |   |   |   |

Parses a JSON string into an object.

Parameters
:

    |---|---|
    | json | The JSON string to parse. |
    | error | If not nil, the location at which to store a pointer to an [**NSError**](https://goo.gl/WJbrdL) if the parsing fails. |


Returns
:   The root object of the object hierarchy that represents the data (either an [**NSArray**](https://goo.gl/q3tY5n) or an [**NSDictionary**](https://goo.gl/0kFoNp)), or `nil` if the parsing failed.

|---|---|---|---|---|
| + (NSString \*) writeJSON: |   | (id) | *object* |   |

Writes an object hierarchy of data to a JSON string.

Parameters
:

    |---|---|
    | object | The root object of the object hierarchy to encode. This must be either an [**NSArray**](https://goo.gl/q3tY5n) or an [**NSDictionary**](https://goo.gl/0kFoNp). |


Returns
:   An [**NSString**](https://goo.gl/5dXzU6) containing the JSON encoding, or `nil` if the data could not be encoded.

|---|---|---|---|
| + (BOOL) isJSONString: |   | (NSString \*) | *actual* |
| equivalentTo: |   | (NSString \*) | *expected* |
|   |   |   |   |

Tests if two JSON strings are equivalent.

This does a deep comparison of the JSON data in the two strings, but ignores any differences in the ordering of keys within a JSON object. For example, `{ "width":64, "height":32 }` is considered to be equivalent to `{ "height":32, "width":64 }`.

|---|---|---|---|
| + (BOOL) isJSONObject: |   | (id) | *actual* |
| equivalentTo: |   | (id) | *expected* |
|   |   |   |   |

Tests if two JSON objects are equivalent.

This does a deep comparison of the JSON data in the two objects, but ignores any differences in the ordering of keys within a JSON object. For example, `{ "width":64, "height":32 }` is considered to be equivalent to `{ "height":32, "width":64 }`.