# serialize

(plugins.serialize)

## Overview

The `serialize` plugin provides essential tools for working with JSON data, allowing objects to be serialized into JSON text and deserialized back into JavaScript objects.

The `toJSON` method converts a JavaScript object into a JSON string, enabling data to be stored or transmitted in a lightweight format.

Conversely, the `fromJSON` method transforms a JSON string back into its original JavaScript object representation.

## Methods Summarized

| Type                                                     | Name                             | Summary                                  |
| -------------------------------------------------------- | -------------------------------- | ---------------------------------------- |
| [Object](/reference/servoycore/dev-api/js-lib/object.md) | [fromJSON(data)](#fromjson-data) | Deserialize from JSON text to an object. |
| [String](/reference/servoycore/dev-api/js-lib/string.md) | [toJSON(obj)](#tojson-obj)       | Serialize an object to JSON text.        |

## Methods Detailed

### fromJSON(data)

Deserialize from JSON text to an object.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **data** ;

**Returns:** [Object](/reference/servoycore/dev-api/js-lib/object.md) The deserialized object from the provided JSON string.

**Sample**

```js
var org_array = new Array('A1','F1','Paris-Dakar');
var string_data = plugins.serialize.toJSON(org_array);
var new_array = plugins.serialize.fromJSON(string_data);
application.output(new_array.join('#'));
```

### toJSON(obj)

Serialize an object to JSON text.

**Parameters**

* [Object](/reference/servoycore/dev-api/js-lib/object.md) **obj** ;

**Returns:** [String](/reference/servoycore/dev-api/js-lib/string.md) The JSON string representation of the serialized object.

**Sample**

```js
var org_array = new Array('A1','F1','Paris-Dakar');
var string_data = plugins.serialize.toJSON(org_array);
var new_array = plugins.serialize.fromJSON(string_data);
application.output(new_array.join('#'));
```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/reference/servoyextensions/server-plugins/serialize.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
