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

Deserialize from JSON text to an object.

Serialize an object to JSON text.

Methods Detailed

fromJSON(data)

Deserialize from JSON text to an object.

Parameters

Returns: Object

Sample

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

Returns: String

Sample

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('#'));

Last updated