Started

Selectors

Utilities

Animation

AJAX

CSS

Event

Manipulation

Cookie

String

Attributes

Data

Storage

Miscellaneous

$json.encode

Encode JSON data to string
$json.encode( json )
  1. json [object/string/number/boolean]
    The JavaScript data that will be stringified.

Notes

It is useful to convert the JavaScript data into a string for data exchange or storage.

Example

HTML code
<button onclick="start_encode()">start JSON encode</button>
JavaScript code
function start_encode()
{
	var data = {
		"name": "tom",
		"age": 18,
		"phone": "010-123456",
		"color": ["red", "black", "white", "yellow"]
	};

	alert("Stringified JSON: " + $json.encode(data));
}
Demonstration