Open Source Cross-Platform Game Programming

Json

Library for parsing JSON.

enum JsonSerializerFlag[link]

Bitmasked enum options for the JSON serializer.

NameDescription
DEFAULT

Bitmask of 0. Indicates the absence of other option flags.

PRETTY

When enabled, includes whitespace in the output.

OMIT_DICTIONARY_NULLS

Dictionary keys that have null values will not be serialized.

function parseJson(rawJsonString, failSilently)[link]

Parses the JSON string into a dictionary object.

Arguments

NameTypeOptionalDescription
rawJsonString string

Raw input text to parse.

failSilently boolean Optional

Default is false. If true, syntax errors will not cause an exception and null will be returned instead.

Return Value

TypeDescription
dictionary

A structured JSON object in the form of a dictionary.

function serialize(object, flags, depth)[link]

Serializes a dictionary object into a JSON string.

Arguments

NameTypeOptionalDescription
object dictionary

Dictionary object to serialize into JSON.

flags Json.JsonSerializerFlag Optional

Bitmask of flags for special options. See JsonSerializerFlag for more information. Default value is JsonSerializerFlag.DEFAULT

depth integer Optional

To prevent infinite recursion, this is a maximum recursion depth. Default value is 64.

Return Value

TypeDescription
string

A JSON string.

class JsonException[link]

An exception thrown upon a parsing or serializing error.