Extracted from Pike v7.8 release 866 at 2016-11-06.
pike.ida.liu.se
[Top]
Standards
Standards.JSON

Method Standards.JSON.encode()


Method encode

string encode(int|float|string|array|mapping|object val, void|int flags)

Description

Encodes a value to a JSON string.

Parameter val

The value to encode. It can contain integers, floats (except the special numbers NaN and infinity), strings, arrays, mappings with string indices, and the special object values null , true and false defined in this module (or really any object that implements an encode_json callback).

Parameter flags

Flag bit field to control formatting. See ASCII_ONLY , HUMAN_READABLE and PIKE_CANONICAL for further details.

Note

8-bit and wider characters in input strings are neither escaped nor utf-8 encoded by default. string_to_utf8 can be used safely on the returned string to get a valid transport encoded JSON string. See escape_string for further details on string escaping.

See also

escape_string