# JSON Utility

## JSON Utility

### Create New Json File

<div data-full-width="false"><figure><img src="https://3435697989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY0AaujVx04fAwfuhX6eu%2Fuploads%2FB4DeRP4KwIFfSyAEiR6c%2FCreateNewJSONFile.png?alt=media&#x26;token=9a5d22fc-43d2-4498-9395-bedb77b25027" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}

### Create New Json File

## Overview

Creates a new, empty JSON object for use in further JSON operations. This node is typically the starting point when building a new JSON structure from scratch. Once created, fields can be added using the various [**Set JSON Field nodes**](https://doc.uforge.co.uk/websocket-pro/documentation/json-set)**.**

## Inputs

**None.**

## Outputs

* **Success** – Returns true if the JSON object was successfully created.
* **Json Object** – The newly created empty JSON object, ready for data to be added.
  {% endhint %}

***

### Convert Json To String

<div data-full-width="false"><figure><img src="https://3435697989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY0AaujVx04fAwfuhX6eu%2Fuploads%2FR1XKalcquTxNLrn92Q5U%2FConvertJSONToString.png?alt=media&#x26;token=6ff8087e-c614-4c03-9256-2442ec119791" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}

### Convert Json To String

## Overview

Converts a JSON object into a string format for storage, string manipulation or display. This node serializes the given JSON object into a text-based JSON string. Optionally, you can enable **Pretty Print** to format the output with indentation and line breaks for easier readability.

## Inputs

* **JSON Object** – The JSON object you want to convert into a string.
* **Pretty Print** – If checked, the output string will be human-readable with line breaks and indentation. If unchecked, the result will be compact.

## Outputs

* **Success** – Returns true if the JSON object was successfully converted to a string. Otherwise returns false.
* **JSON String** – The serialized string representation of the input JSON object.
  {% endhint %}

***

### String To Json Object

<div data-full-width="false"><figure><img src="https://3435697989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY0AaujVx04fAwfuhX6eu%2Fuploads%2FHAETkTRzRbrSrq7n6vcV%2FStringToJSONObject.png?alt=media&#x26;token=4a0b4ddd-f926-47c1-a347-c2703f7afc9f" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}

### String To Json Object

## Overview

Parses a JSON-formatted string and converts it into a usable JSON object. This node is typically used to deserialize data that was loaded from a file, received from a server, for quick debugging and testing.

**Note:** The input string must be a valid JSON. If the format is incorrect or malformed, the conversion will fail and return an empty or null object.

## Inputs

* **Raw String Data** – A string containing valid JSON text that you want to parse into a JSON object.

## Outputs

* **Success** – Returns true if the string was successfully parsed into a JSON object. Otherwise, returns false.
* Loaded Json Object - The resulting JSON object that can be used with other JSON nodes.
  {% endhint %}

***

### Remove Json Field

<div data-full-width="false"><figure><img src="https://3435697989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY0AaujVx04fAwfuhX6eu%2Fuploads%2FFrz0pH6tPMoWYONWyQTA%2FRemoveJSONField.png?alt=media&#x26;token=386a43dc-a879-42fe-bb6a-5abbddd26890" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}

### Remove Json Field

## Overview

Removes a specific field (**key–value pair**) from a given JSON object. This node returns a new JSON object identical to the input, except without the specified field. This is useful for cleaning structures before saving, serializing, or sending.

**Note:** If the specified field does not exist, the original object is returned unchanged, and **Success** is set to false.

## Inputs

* **JSON Object** – The input JSON object from which you want to remove a field.
* **Field Name** – The name of the field (**as string**) to remove from the JSON object.

## Outputs

* **Success** – Returns true if the field was found and successfully removed. Otherwise, returns false.
* **New Json Object** - A copy of the input JSON object with the specified field removed (**if found**).
  {% endhint %}

***

### Has Field

<div data-full-width="false"><figure><img src="https://3435697989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY0AaujVx04fAwfuhX6eu%2Fuploads%2FbCkQVuyYMep2imE9Vz9t%2FHasField.png?alt=media&#x26;token=72e2a958-5dea-4c80-95eb-990cd8827798" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
Has Field

## Overview

Checks whether a specified field (**key**) exists within a given JSON object. This node is useful for verifying the presence of data before attempting to retrieve or operate on a specific field, helping prevent errors and ensure safer parsing.

**Note:** This node only checks the top-level of the provided JSON object. It does not search nested objects.

## Inputs

* **JSON Object** – The JSON object in which you want to search for a field.
* **Field to Find** – The name of the field (**as string**) to check for existence.

## Outputs

* **Success** – Returns true if the specified field exists in the JSON object. Otherwise, returns false.
  {% endhint %}
