Class: JSON

SuperMap.Format.JSON

Parse class for safely reading and writing JSON. Create a new instance using SuperMap.Format.JSON constructor.

new SuperMap.Format.JSON()

JSON.js, line 4

Extends

Members

dataObject

When the keepData attribute is set to true, This is the string that is passed to the read operation to be parsed.

indentstring

Format output. For every indent, the indent string will use one time.

keepDataObject

Keep a reference to the data that is read recently (through the attribute). The default value is false

levelinteger

use formatted output, the indentation level is expressed.

nativeJSONboolean

Determine whether browsers are native to support JSON format data.

newlinestring

Format output. newline string will be used for each name value pair or the last number of array.

Default Value:
'\n'

optionsObject

The optional parameters.

prettyboolean

Whether to use words wrap and indent to control the output.

serialize

A method of providing a number of type objects to a JSON string.

spacestring

Format output. space string wil be added after the name value pair ":".

Methods

inherited destroy()

Format.js, line 39

Disposes the resource. The property that references resource is set to null.

read(json, filter){Object}

JSON.js, line 209

Parsing a string conforming to the JSON structure.

Name Type Description
json string

A string that conforms to the JSON structure.

filter function

The filtering method, each of the key value pairs of the final result will call the filter method and replace the value returned by the location of the corresponding value.

Returns:
Type Description
Object Object, array, string, or number.

write(value, pretty){string}

JSON.js, line 233

Serialize an object to a string that conforms to the JSON format.

Name Type Description
value object | string | Array | number | boolean

object, array, string, number, boolean that needs to be serialized.

pretty boolean optional

Whether to use words wrap and indent to control the output.

Returns:
Type Description
string String conforming to JSON format

writeIndent(){string}

JSON.js, line 257

A indentation string is output according to the indentation level.

Returns:
Type Description
string An appropriate indentation string.

writeNewline(){string}

JSON.js, line 272

A string representing a new line is output in the format of formatted output mode.

Returns:
Type Description
string A string representing a new line.

writeSpace(){string}

JSON.js, line 281

Output a string representing a space in the format of formatted output mode.

Returns:
Type Description
string A space.