Source2Toolkit
Core api

IToolkitJSON

IToolkitJSON

IToolkitJSONValue

bool IsNull()

bool IsObject()

bool IsArray()

bool IsString()

bool IsNumber()

bool IsBool()

bool Has(pszKey)

@brief Whether this object has the key. False for anything but an object.

Parameters
  • pszKey const char*

const IToolkitJSONValue* Get(pszKey)

@brief The value at a key, or null when absent or not an object.

Parameters
  • pszKey const char*

int Count()

@brief Elements in an array, or members in an object. Zero otherwise.

const IToolkitJSONValue* At(nIndex)

@brief The element at an index, or null when out of range or not an array.

Parameters
  • nIndex int

const char* KeyAt(nIndex)

@brief The key of the member at an index, for walking an object. Null when out of range or not an object.

Parameters
  • nIndex int

const char* AsString(pszDefault)

This node's value, or pszDefault when it is not a string.

Parameters
  • pszDefault const char*

int64_t AsInt64(nDefault)

Parameters
  • nDefault int64_t

int AsInt(nDefault)

Parameters
  • nDefault int

double AsDouble(flDefault)

Parameters
  • flDefault double

float AsFloat(flDefault)

Parameters
  • flDefault float

bool AsBool(bDefault)

Parameters
  • bDefault bool

const char* GetString(pszKey, pszDefault)

@brief Shorthand for Get(key) then the matching As*, with the default when the key is missing or the wrong type.

Parameters
  • pszKey const char*
  • pszDefault const char*

int64_t GetInt64(pszKey, nDefault)

Parameters
  • pszKey const char*
  • nDefault int64_t

int GetInt(pszKey, nDefault)

Parameters
  • pszKey const char*
  • nDefault int

double GetDouble(pszKey, flDefault)

Parameters
  • pszKey const char*
  • flDefault double

float GetFloat(pszKey, flDefault)

Parameters
  • pszKey const char*
  • flDefault float

bool GetBool(pszKey, bDefault)

Parameters
  • pszKey const char*
  • bDefault bool

const char* Dump(nIndent)

This node serialised back to text.

Parameters
  • nIndent int — Spaces per level, or -1 for the compact form.

IToolkitJSONDocument

bool IsValid()

@brief Whether the text parsed. A failed parse still returns a document, whose root reads as null, so a caller can skip the check.

const char* GetError()

@brief The parser's complaint, or an empty string when IsValid().

const IToolkitJSONValue* Root()

Release()

@brief Frees the document and everything reached through it.

IToolkitJSON

IToolkitJSONDocument* Parse(pszText, nLength)

Parses text into a document the caller then owns.

Parameters
  • pszText const char* — JSON text.
  • nLength int — Length, or -1 to read up to the terminator.

On this page