TypedStringMap

Inherits StringMap

A StringMap with typed getters and setters.

Properties

Length

int (read-only)

For more information, see StringMap.Size.

Signature

1property int Length { get; }

Methods

HasKey

For more information, see StringMap.ContainsKey.

Arguments
  • key const char[]

Returns
    • bool

    Signature

    1bool HasKey(const char[] key)
    

    GetInt

    Retrieves the int stored at a key.

    Arguments
    • key const char[]

    • Key to retrieve int value for.

    • default_value int

    • Value to return if the key does not exist. default: -1

    Returns
      • int
      • Value stored at key.

      Signature

      1int GetInt(const char[] key, int default_value = -1)
      

      GetFloat

      Retrieves the float stored at a key.

      Arguments
      • key const char[]

      • Key to retrieve float value for.

      • default_value float

      • Value to return if the key does not exist. default: -1.0

      Returns
        • float
        • Value stored at key.

        Signature

        1float GetFloat(const char[] key, float default_value = -1.0)
        

        GetBool

        Retrieves the bool stored at a key.

        Arguments
        • key const char[]

        • Key to retrieve bool value for.

        • default_value bool

        • Value to return if the key does not exist. default: false

        Returns
          • bool
          • Value stored at key.

          Signature

          1bool GetBool(const char[] key, bool default_value = false)
          

          GetHandle

          Retrieves the handle stored at a key.

          Arguments
          • key const char[]

          • Key to retrieve handle value for.

          • default_value Handle

          • Value to return if the key does not exist. default: null

          Returns
            • Handle
            • Value stored at key.

            Signature

            1Handle GetHandle(const char[] key, Handle default_value = null)
            

            SetInt

            Sets the int stored at a key.

            Arguments
            • key const char[]

            • Key to set to int value.

            • value int

            • Value to set.

            Returns
              • bool
              • True on success, false otherwise.

              Signature

              1bool SetInt(const char[] key, int value)
              

              SetFloat

              Sets the float stored at a key.

              Arguments
              • key const char[]

              • Key to set to float value.

              • value float

              • Value to set.

              Returns
                • bool
                • True on success, false otherwise.

                Signature

                1bool SetFloat(const char[] key, float value)
                

                SetBool

                Sets the bool stored at a key.

                Arguments
                • key const char[]

                • Key to set to bool value.

                • value bool

                • Value to set.

                Returns
                  • bool
                  • True on success, false otherwise.

                  Signature

                  1bool SetBool(const char[] key, bool value)
                  

                  SetHandle

                  Sets the handle stored at a key.

                  Arguments
                  • key const char[]

                  • Key to set to object value.

                  • value Handle

                  • Value to set.

                  Returns
                    • bool
                    • True on success, false otherwise.

                    Signature

                    1bool SetHandle(const char[] key, Handle value)
                    

                    TypedStringMap

                    Creates a new TypedStringMap.

                    Returns
                    • A new TypedStringMap.

                    Signature

                    1TypedStringMap()
                    

                    MetaStringMap

                    Inherits TypedStringMap

                    A TypedStringMap which contains a nested Data TypedStringMap property. Standard methods and properties have been overridden to run against Data, but you can access the parent methods/properties using the Meta property.

                    Properties

                    Meta

                    TypedStringMap (read-only)

                    Views the instance as its superclass to access overridden methods.

                    Signature

                    1property TypedStringMap Meta { get; }
                    

                    Data

                    TypedStringMap

                    Gets the nested stringmap where data is stored.

                    Signature

                    1property TypedStringMap Data { get; set; }
                    

                    Length

                    int (read-only)

                    For more information, see TypedStringMap.Length.

                    Signature

                    1property int Length { get; }
                    

                    Methods

                    GetValue

                    For more information, see StringMap.GetValue.

                    Arguments
                    • key const char[]

                    • &value any

                    Returns
                      • bool

                      Signature

                      1bool GetValue(const char[] key, any &value)
                      

                      GetString

                      For more information, see StringMap.GetString.

                      Arguments
                      • key const char[]

                      • value char[]

                      • max_size int

                      • &size int

                      • default: 0

                      Returns
                        • bool

                        Signature

                        1bool GetString(const char[] key, char[] value, int max_size, int &size = 0)
                        

                        GetInt

                        For more information, see TypedStringMap.GetInt.

                        Arguments
                        • key const char[]

                        • default_value int

                        • default: -1

                        Returns
                          • int

                          Signature

                          1int GetInt(const char[] key, int default_value = -1)
                          

                          GetFloat

                          For more information, see TypedStringMap.GetFloat.

                          Arguments
                          • key const char[]

                          • default_value float

                          • default: -1.0

                          Returns
                            • float

                            Signature

                            1float GetFloat(const char[] key, float default_value = -1.0)
                            

                            GetBool

                            For more information, see TypedStringMap.GetBool.

                            Arguments
                            • key const char[]

                            • default_value bool

                            • default: false

                            Returns
                              • bool

                              Signature

                              1bool GetBool(const char[] key, bool default_value = false)
                              

                              GetHandle

                              For more information, see TypedStringMap.GetHandle.

                              Arguments
                              • key const char[]

                              • default_value Handle

                              • default: null

                              Returns
                                • Handle

                                Signature

                                1Handle GetHandle(const char[] key, Handle default_value = null)
                                

                                SetValue

                                For more information, see StringMap.SetValue.

                                Arguments
                                • key const char[]

                                • value any

                                Returns
                                  • bool

                                  Signature

                                  1bool SetValue(const char[] key, any value)
                                  

                                  SetString

                                  For more information, see StringMap.SetString.

                                  Arguments
                                  • key const char[]

                                  • value const char[]

                                  Returns
                                    • bool

                                    Signature

                                    1bool SetString(const char[] key, const char[] value)
                                    

                                    SetInt

                                    For more information, see TypedStringMap.SetInt.

                                    Arguments
                                    • key const char[]

                                    • value int

                                    Returns
                                      • bool

                                      Signature

                                      1bool SetInt(const char[] key, int value)
                                      

                                      SetFloat

                                      For more information, see TypedStringMap.SetFloat.

                                      Arguments
                                      • key const char[]

                                      • value float

                                      Returns
                                        • bool

                                        Signature

                                        1bool SetFloat(const char[] key, float value)
                                        

                                        SetBool

                                        For more information, see TypedStringMap.SetBool.

                                        Arguments
                                        • key const char[]

                                        • value bool

                                        Returns
                                          • bool

                                          Signature

                                          1bool SetBool(const char[] key, bool value)
                                          

                                          SetHandle

                                          For more information, see TypedStringMap.SetHandle.

                                          Arguments
                                          • key const char[]

                                          • value Handle

                                          Returns
                                            • bool

                                            Signature

                                            1bool SetHandle(const char[] key, Handle value)
                                            

                                            Remove

                                            For more information, see StringMap.Remove.

                                            Arguments
                                            • key const char[]

                                            Returns
                                              • bool

                                              Signature

                                              1bool Remove(const char[] key)
                                              

                                              HasKey

                                              For more information, see TypedStringMap.HasKey.

                                              Arguments
                                              • key const char[]

                                              Returns
                                                • bool

                                                Signature

                                                1bool HasKey(const char[] key)
                                                

                                                Clear

                                                For more information, see StringMap.Clear.

                                                Signature

                                                1void Clear()
                                                

                                                Cleanup

                                                Deletes the instance’s data StringMap as well as the instance itself.

                                                Signature

                                                1void Cleanup()
                                                

                                                Snapshot

                                                For more information, see StringMap.Snapshot.

                                                Returns
                                                • StringMapSnapshot

                                                Signature

                                                1StringMapSnapshot Snapshot()
                                                

                                                MetaStringMap

                                                Creates a new MetaStringMap.

                                                Returns
                                                • A new MetaStringMap.

                                                Signature

                                                1MetaStringMap()
                                                

                                                JSON_Object

                                                Inherits MetaStringMap

                                                Properties

                                                Super

                                                MetaStringMap (read-only)

                                                Views the instance as its superclass to access overridden methods.

                                                Signature

                                                1property MetaStringMap Super { get; }
                                                

                                                IsArray

                                                bool (read-only)

                                                Whether the current object is an array.

                                                Signature

                                                1property bool IsArray { get; }
                                                

                                                Methods

                                                GetType

                                                Gets the cell type stored at a key.

                                                Arguments
                                                • key const char[]

                                                • Key to get value type for.

                                                Returns
                                                  • JSONCellType
                                                  • Value type for key provided, or JSON_Type_Invalid if it does not exist.

                                                  Signature

                                                  1JSONCellType GetType(const char[] key)
                                                  

                                                  GetSize

                                                  Gets the size of the string stored at a key.

                                                  Arguments
                                                  • key const char[]

                                                  • Key to get buffer size for.

                                                  Returns
                                                    • int
                                                    • Buffer size for string at key provided, or -1 if it is not a string/does not exist.

                                                    Signature

                                                    1int GetSize(const char[] key)
                                                    

                                                    GetHidden

                                                    Gets whether the key should be hidden from encoding.

                                                    Arguments
                                                    • key const char[]

                                                    • Key to get hidden state for.

                                                    Returns
                                                      • bool
                                                      • Whether or not the key should be hidden.

                                                      Signature

                                                      1bool GetHidden(const char[] key)
                                                      

                                                      GetIndex

                                                      Gets the index of a key.

                                                      Arguments
                                                      • key const char[]

                                                      • Key to get index of.

                                                      Returns
                                                        • int
                                                        • Index of the key provided, or -1 if it does not exist.

                                                        Signature

                                                        1int GetIndex(const char[] key)
                                                        

                                                        GetKey

                                                        Gets the key stored at an index. If an array, will convert the index to its string value. If an array, will return false if the index is not between [0, length].

                                                        Arguments
                                                        • index int

                                                        • Index of key.

                                                        • value char[]

                                                        • Buffer to store key at.

                                                        • max_size int

                                                        • Maximum size of value buffer.

                                                        Returns
                                                          • bool
                                                          • True on success, false otherwise.

                                                          Signature

                                                          1bool GetKey(int index, char[] value, int max_size)
                                                          

                                                          GetKeySize

                                                          Returns the buffer size required to store the key at the specified index.

                                                          Arguments
                                                          • index int

                                                          • Index of key.

                                                          Returns
                                                            • int
                                                            • Buffer size required to store key.

                                                            Signature

                                                            1int GetKeySize(int index)
                                                            

                                                            SetHidden

                                                            Sets whether the key should be hidden from encoding.

                                                            Arguments
                                                            • key const char[]

                                                            • Key to set hidden state for.

                                                            • hidden bool

                                                            • Whether or not the key should be hidden.

                                                            Returns
                                                              • bool
                                                              • True on success, false otherwise.

                                                              Signature

                                                              1bool SetHidden(const char[] key, bool hidden)
                                                              

                                                              GetInt64

                                                              Retrieves the int64 stored at a key.

                                                              Arguments
                                                              • key const char[]

                                                              • Key to retrieve int64 value for.

                                                              • value int[2]

                                                              • Int buffer to store output.

                                                              Returns
                                                                • bool
                                                                • True on success, false otherwise.

                                                                Signature

                                                                1bool GetInt64(const char[] key, int value[2])
                                                                

                                                                GetObject

                                                                Retrieves the JSON object stored at a key.

                                                                Arguments
                                                                • key const char[]

                                                                • Key to retrieve object value for.

                                                                • default_value JSON_Object

                                                                • Value to return if the key does not exist. default: null

                                                                Returns
                                                                  • JSON_Object
                                                                  • Value stored at key.

                                                                  Signature

                                                                  1JSON_Object GetObject(const char[] key, JSON_Object default_value = null)
                                                                  

                                                                  SetString

                                                                  Sets the string stored at a key.

                                                                  Arguments
                                                                  • key const char[]

                                                                  • Key to set to string value.

                                                                  • value const char[]

                                                                  • Value to set.

                                                                  Returns
                                                                    • bool
                                                                    • True on success, false otherwise.

                                                                    Signature

                                                                    1bool SetString(const char[] key, const char[] value)
                                                                    

                                                                    SetInt

                                                                    Sets the int stored at a key.

                                                                    Arguments
                                                                    • key const char[]

                                                                    • Key to set to int value.

                                                                    • value int

                                                                    • Value to set.

                                                                    Returns
                                                                      • bool
                                                                      • True on success, false otherwise.

                                                                      Signature

                                                                      1bool SetInt(const char[] key, int value)
                                                                      

                                                                      SetInt64

                                                                      Sets the int64 stored at a key.

                                                                      Arguments
                                                                      • key const char[]

                                                                      • Key to set to int64 value.

                                                                      • value int[2]

                                                                      • Value to set.

                                                                      Returns
                                                                        • bool
                                                                        • True on success, false otherwise.

                                                                        Signature

                                                                        1bool SetInt64(const char[] key, int value[2])
                                                                        

                                                                        SetFloat

                                                                        Sets the float stored at a key.

                                                                        Arguments
                                                                        • key const char[]

                                                                        • Key to set to float value.

                                                                        • value float

                                                                        • Value to set.

                                                                        Returns
                                                                          • bool
                                                                          • True on success, false otherwise.

                                                                          Signature

                                                                          1bool SetFloat(const char[] key, float value)
                                                                          

                                                                          SetBool

                                                                          Sets the bool stored at a key.

                                                                          Arguments
                                                                          • key const char[]

                                                                          • Key to set to bool value.

                                                                          • value bool

                                                                          • Value to set.

                                                                          Returns
                                                                            • bool
                                                                            • True on success, false otherwise.

                                                                            Signature

                                                                            1bool SetBool(const char[] key, bool value)
                                                                            

                                                                            SetObject

                                                                            Sets the JSON object stored at a key.

                                                                            Arguments
                                                                            • key const char[]

                                                                            • Key to set to object value.

                                                                            • value JSON_Object

                                                                            • Value to set.

                                                                            Returns
                                                                              • bool
                                                                              • True on success, false otherwise.

                                                                              Signature

                                                                              1bool SetObject(const char[] key, JSON_Object value)
                                                                              

                                                                              Remove

                                                                              Removes an item from the object by key.

                                                                              Arguments
                                                                              • key const char[]

                                                                              • Key of object to remove.

                                                                              Returns
                                                                                • bool
                                                                                • True on success, false if the value was never set.

                                                                                Signature

                                                                                1bool Remove(const char[] key)
                                                                                

                                                                                Rename

                                                                                Renames the key of an existing item in the object.

                                                                                Arguments
                                                                                • from const char[]

                                                                                • Existing key to rename.

                                                                                • to const char[]

                                                                                • New key.

                                                                                • replace bool

                                                                                • Should the ‘to’ key should be replaced if it exists? default: true

                                                                                Returns
                                                                                  • bool
                                                                                  • True on success, false otherwise.

                                                                                  Signature

                                                                                  1bool Rename(const char[] from, const char[] to, bool replace = true)
                                                                                  

                                                                                  Merge

                                                                                  Merges in the entries from the specified object, optionally replacing existing entries with the same key.

                                                                                  Arguments
                                                                                  • from JSON_Object

                                                                                  • Object to merge entries from.

                                                                                  • options int

                                                                                  • Bitwise combination of JSON_MERGE_* options. default: JSON_MERGE_REPLACE

                                                                                  Returns
                                                                                    • bool
                                                                                    • True on success, false otherwise.
                                                                                    Throws
                                                                                    • If the object being merged is an array, an error will be thrown.

                                                                                    Signature

                                                                                    1bool Merge(JSON_Object from, int options = JSON_MERGE_REPLACE)
                                                                                    

                                                                                    EncodeSize

                                                                                    Makes a global call with this instance passed as the object.

                                                                                    For more information, see json_encode_size.

                                                                                    Arguments
                                                                                    • options int

                                                                                    • default: JSON_NONE

                                                                                    Returns
                                                                                      • int

                                                                                      Signature

                                                                                      1int EncodeSize(int options = JSON_NONE)
                                                                                      

                                                                                      Encode

                                                                                      Makes a global call with this instance passed as the object.

                                                                                      For more information, see json_encode.

                                                                                      Arguments
                                                                                      • output char[]

                                                                                      • max_size int

                                                                                      • options int

                                                                                      • default: JSON_NONE

                                                                                      Signature

                                                                                      1void Encode(char[] output, int max_size, int options = JSON_NONE)
                                                                                      

                                                                                      WriteToFile

                                                                                      Makes a global call with this instance passed as the object.

                                                                                      For more information, see json_write_to_file.

                                                                                      Arguments
                                                                                      • path const char[]

                                                                                      • options int

                                                                                      • default: JSON_NONE

                                                                                      Returns
                                                                                        • bool

                                                                                        Signature

                                                                                        1bool WriteToFile(const char[] path, int options = JSON_NONE)
                                                                                        

                                                                                        ShallowCopy

                                                                                        Makes a global call with this instance passed as the object.

                                                                                        For more information, see json_copy_deep.

                                                                                        Returns
                                                                                        • JSON_Object

                                                                                        Signature

                                                                                        1JSON_Object ShallowCopy()
                                                                                        

                                                                                        DeepCopy

                                                                                        Makes a global call with this instance passed as the object.

                                                                                        For more information, see json_copy_deep.

                                                                                        Returns
                                                                                        • JSON_Object

                                                                                        Signature

                                                                                        1JSON_Object DeepCopy()
                                                                                        

                                                                                        Cleanup

                                                                                        Makes a global call with this instance passed as the object.

                                                                                        For more information, see json_cleanup.

                                                                                        Signature

                                                                                        1void Cleanup()
                                                                                        

                                                                                        JSON_Object

                                                                                        Creates a new JSON_Object.

                                                                                        Returns
                                                                                        • A new JSON_Object.

                                                                                        Signature

                                                                                        1JSON_Object()
                                                                                        

                                                                                        JSON_Array

                                                                                        Inherits JSON_Object

                                                                                        Properties

                                                                                        Super

                                                                                        JSON_Object (read-only)

                                                                                        Views the instance as its superclass to access overridden methods.

                                                                                        Signature

                                                                                        1property JSON_Object Super { get; }
                                                                                        

                                                                                        Methods

                                                                                        CanUseType

                                                                                        Checks whether the array accepts the type provided.

                                                                                        Arguments
                                                                                        • type JSONCellType

                                                                                        • Type to check for enforcement.

                                                                                        Returns
                                                                                          • bool
                                                                                          • True if the type can be used, false otherwise.

                                                                                          Signature

                                                                                          1bool CanUseType(JSONCellType type)
                                                                                          

                                                                                          HasKey

                                                                                          Checks whether the object has an index.

                                                                                          Arguments
                                                                                          • index int

                                                                                          • Index to check existence of.

                                                                                          Returns
                                                                                            • bool
                                                                                            • True if the index exists, false otherwise.

                                                                                            Signature

                                                                                            1bool HasKey(int index)
                                                                                            

                                                                                            GetType

                                                                                            Gets the cell type stored at an index.

                                                                                            Arguments
                                                                                            • index int

                                                                                            • Index to get value type for.

                                                                                            Returns
                                                                                              • JSONCellType
                                                                                              • Value type for index provided, or JSON_Type_Invalid if it does not exist.

                                                                                              Signature

                                                                                              1JSONCellType GetType(int index)
                                                                                              

                                                                                              GetSize

                                                                                              Gets the length of the string stored at an index.

                                                                                              Arguments
                                                                                              • index int

                                                                                              • Index to get string length for.

                                                                                              Returns
                                                                                                • int
                                                                                                • Length of string at index provided, or -1 if it is not a string/does not exist.

                                                                                                Signature

                                                                                                1int GetSize(int index)
                                                                                                

                                                                                                GetHidden

                                                                                                Gets whether the index should be hidden from encoding.

                                                                                                Arguments
                                                                                                • index int

                                                                                                • Index to get hidden state for.

                                                                                                Returns
                                                                                                  • bool
                                                                                                  • Whether or not the index should be hidden.

                                                                                                  Signature

                                                                                                  1bool GetHidden(int index)
                                                                                                  

                                                                                                  SetHidden

                                                                                                  Sets whether the index should be hidden from encoding.

                                                                                                  Arguments
                                                                                                  • index int

                                                                                                  • Index to set hidden state for.

                                                                                                  • hidden bool

                                                                                                  • Whether or not the index should be hidden.

                                                                                                  Returns
                                                                                                    • bool
                                                                                                    • True on success, false otherwise.

                                                                                                    Signature

                                                                                                    1bool SetHidden(int index, bool hidden)
                                                                                                    

                                                                                                    GetValue

                                                                                                    Converts index to a string (‘key’) and calls the relevant Super method.

                                                                                                    For more information, see MetaStringMap.GetValue.

                                                                                                    Arguments
                                                                                                    • index int

                                                                                                    • &value any

                                                                                                    Returns
                                                                                                      • bool

                                                                                                      Signature

                                                                                                      1bool GetValue(int index, any &value)
                                                                                                      

                                                                                                      GetString

                                                                                                      Converts index to a string (‘key’) and calls the relevant Super method.

                                                                                                      For more information, see MetaStringMap.GetString.

                                                                                                      Arguments
                                                                                                      • index int

                                                                                                      • value char[]

                                                                                                      • max_size int

                                                                                                      • &size int

                                                                                                      • default: 0

                                                                                                      Returns
                                                                                                        • bool

                                                                                                        Signature

                                                                                                        1bool GetString(int index, char[] value, int max_size, int &size = 0)
                                                                                                        

                                                                                                        GetInt

                                                                                                        Converts index to a string (‘key’) and calls the relevant Super method.

                                                                                                        For more information, see MetaStringMap.GetInt.

                                                                                                        Arguments
                                                                                                        • index int

                                                                                                        • default_value int

                                                                                                        • default: -1

                                                                                                        Returns
                                                                                                          • int

                                                                                                          Signature

                                                                                                          1int GetInt(int index, int default_value = -1)
                                                                                                          

                                                                                                          GetInt64

                                                                                                          Converts index to a string (‘key’) and calls the relevant Super method.

                                                                                                          For more information, see JSON_Object.GetInt64.

                                                                                                          Arguments
                                                                                                          • index int

                                                                                                          • value int[2]

                                                                                                          Returns
                                                                                                            • bool

                                                                                                            Signature

                                                                                                            1bool GetInt64(int index, int value[2])
                                                                                                            

                                                                                                            GetFloat

                                                                                                            Converts index to a string (‘key’) and calls the relevant Super method.

                                                                                                            For more information, see MetaStringMap.GetFloat.

                                                                                                            Arguments
                                                                                                            • index int

                                                                                                            • default_value float

                                                                                                            • default: -1.0

                                                                                                            Returns
                                                                                                              • float

                                                                                                              Signature

                                                                                                              1float GetFloat(int index, float default_value = -1.0)
                                                                                                              

                                                                                                              GetBool

                                                                                                              Converts index to a string (‘key’) and calls the relevant Super method.

                                                                                                              For more information, see MetaStringMap.GetBool.

                                                                                                              Arguments
                                                                                                              • index int

                                                                                                              • default_value bool

                                                                                                              • default: false

                                                                                                              Returns
                                                                                                                • bool

                                                                                                                Signature

                                                                                                                1bool GetBool(int index, bool default_value = false)
                                                                                                                

                                                                                                                GetObject

                                                                                                                Converts index to a string (‘key’) and calls the relevant Super method.

                                                                                                                For more information, see MetaStringMap.GetObject.

                                                                                                                Arguments
                                                                                                                • index int

                                                                                                                • default_value JSON_Object

                                                                                                                • default: null

                                                                                                                Returns
                                                                                                                  • JSON_Object

                                                                                                                  Signature

                                                                                                                  1JSON_Object GetObject(int index, JSON_Object default_value = null)
                                                                                                                  

                                                                                                                  SetString

                                                                                                                  Converts index to a string (‘key’) and calls the relevant Super method.

                                                                                                                  For more information, see JSON_Object.SetString.

                                                                                                                  Arguments
                                                                                                                  • index int

                                                                                                                  • value const char[]

                                                                                                                  Returns
                                                                                                                    • bool

                                                                                                                    Signature

                                                                                                                    1bool SetString(int index, const char[] value)
                                                                                                                    

                                                                                                                    SetInt

                                                                                                                    Converts index to a string (‘key’) and calls the relevant Super method.

                                                                                                                    For more information, see JSON_Object.SetInt.

                                                                                                                    Arguments
                                                                                                                    • index int

                                                                                                                    • value int

                                                                                                                    Returns
                                                                                                                      • bool

                                                                                                                      Signature

                                                                                                                      1bool SetInt(int index, int value)
                                                                                                                      

                                                                                                                      SetInt64

                                                                                                                      Converts index to a string (‘key’) and calls the relevant Super method.

                                                                                                                      For more information, see JSON_Object.SetInt64.

                                                                                                                      Arguments
                                                                                                                      • index int

                                                                                                                      • value int[2]

                                                                                                                      Returns
                                                                                                                        • bool

                                                                                                                        Signature

                                                                                                                        1bool SetInt64(int index, int value[2])
                                                                                                                        

                                                                                                                        SetFloat

                                                                                                                        Converts index to a string (‘key’) and calls the relevant Super method.

                                                                                                                        For more information, see JSON_Object.SetFloat.

                                                                                                                        Arguments
                                                                                                                        • index int

                                                                                                                        • value float

                                                                                                                        Returns
                                                                                                                          • bool

                                                                                                                          Signature

                                                                                                                          1bool SetFloat(int index, float value)
                                                                                                                          

                                                                                                                          SetBool

                                                                                                                          Converts index to a string (‘key’) and calls the relevant Super method.

                                                                                                                          For more information, see JSON_Object.SetBool.

                                                                                                                          Arguments
                                                                                                                          • index int

                                                                                                                          • value bool

                                                                                                                          Returns
                                                                                                                            • bool

                                                                                                                            Signature

                                                                                                                            1bool SetBool(int index, bool value)
                                                                                                                            

                                                                                                                            SetObject

                                                                                                                            Converts index to a string (‘key’) and calls the relevant Super method.

                                                                                                                            For more information, see JSON_Object.SetObject.

                                                                                                                            Arguments
                                                                                                                            • index int

                                                                                                                            • value JSON_Object

                                                                                                                            Returns
                                                                                                                              • bool

                                                                                                                              Signature

                                                                                                                              1bool SetObject(int index, JSON_Object value)
                                                                                                                              

                                                                                                                              PushString

                                                                                                                              Pushes a string to the end of the array.

                                                                                                                              Arguments
                                                                                                                              • value const char[]

                                                                                                                              • Value to push.

                                                                                                                              Returns
                                                                                                                                • int
                                                                                                                                • The element’s index on success, -1 otherwise.

                                                                                                                                Signature

                                                                                                                                1int PushString(const char[] value)
                                                                                                                                

                                                                                                                                PushInt

                                                                                                                                Pushes an int to the end of the array.

                                                                                                                                Arguments
                                                                                                                                • value int

                                                                                                                                • Value to push.

                                                                                                                                Returns
                                                                                                                                  • int
                                                                                                                                  • The element’s index on success, -1 otherwise.

                                                                                                                                  Signature

                                                                                                                                  1int PushInt(int value)
                                                                                                                                  

                                                                                                                                  PushInt64

                                                                                                                                  Pushes an int64 to the end of the array.

                                                                                                                                  Arguments
                                                                                                                                  • value int[2]

                                                                                                                                  • Value to push.

                                                                                                                                  Returns
                                                                                                                                    • int
                                                                                                                                    • The element’s index on success, -1 otherwise.

                                                                                                                                    Signature

                                                                                                                                    1int PushInt64(int value[2])
                                                                                                                                    

                                                                                                                                    PushFloat

                                                                                                                                    Pushes a float to the end of the array.

                                                                                                                                    Arguments
                                                                                                                                    • value float

                                                                                                                                    • Value to push.

                                                                                                                                    Returns
                                                                                                                                      • int
                                                                                                                                      • The element’s index on success, -1 otherwise.

                                                                                                                                      Signature

                                                                                                                                      1int PushFloat(float value)
                                                                                                                                      

                                                                                                                                      PushBool

                                                                                                                                      Pushes a bool to the end of the array.

                                                                                                                                      Arguments
                                                                                                                                      • value bool

                                                                                                                                      • Value to push.

                                                                                                                                      Returns
                                                                                                                                        • int
                                                                                                                                        • The element’s index on success, -1 otherwise.

                                                                                                                                        Signature

                                                                                                                                        1int PushBool(bool value)
                                                                                                                                        

                                                                                                                                        PushObject

                                                                                                                                        Pushes a JSON object to the end of the array.

                                                                                                                                        Arguments
                                                                                                                                        • value JSON_Object

                                                                                                                                        • Value to push.

                                                                                                                                        Returns
                                                                                                                                          • int
                                                                                                                                          • The element’s index on success, -1 otherwise.

                                                                                                                                          Signature

                                                                                                                                          1int PushObject(JSON_Object value)
                                                                                                                                          

                                                                                                                                          IndexOf

                                                                                                                                          Finds the index of a value in the array.

                                                                                                                                          Arguments
                                                                                                                                          • value any

                                                                                                                                          • Value to search for.

                                                                                                                                          Returns
                                                                                                                                            • int
                                                                                                                                            • The index of the value if it is found, -1 otherwise.

                                                                                                                                            Signature

                                                                                                                                            1int IndexOf(any value)
                                                                                                                                            

                                                                                                                                            IndexOfString

                                                                                                                                            Finds the index of a string in the array.

                                                                                                                                            Arguments
                                                                                                                                            • value const char[]

                                                                                                                                            • String to search for.

                                                                                                                                            Returns
                                                                                                                                              • int
                                                                                                                                              • The index of the string if it is found, -1 otherwise.

                                                                                                                                              Signature

                                                                                                                                              1int IndexOfString(const char[] value)
                                                                                                                                              

                                                                                                                                              Contains

                                                                                                                                              Determines whether the array contains a value.

                                                                                                                                              Arguments
                                                                                                                                              • value any

                                                                                                                                              • Value to search for.

                                                                                                                                              Returns
                                                                                                                                                • bool
                                                                                                                                                • True if the value is found, false otherwise.

                                                                                                                                                Signature

                                                                                                                                                1bool Contains(any value)
                                                                                                                                                

                                                                                                                                                ContainsString

                                                                                                                                                Determines whether the array contains a string.

                                                                                                                                                Arguments
                                                                                                                                                • value const char[]

                                                                                                                                                • String to search for.

                                                                                                                                                Returns
                                                                                                                                                  • bool
                                                                                                                                                  • True if the string is found, false otherwise.

                                                                                                                                                  Signature

                                                                                                                                                  1bool ContainsString(const char[] value)
                                                                                                                                                  

                                                                                                                                                  Remove

                                                                                                                                                  Removes an index and its related meta-keys from the array, and shifts down all following element indices.

                                                                                                                                                  Arguments
                                                                                                                                                  • index int

                                                                                                                                                  Returns
                                                                                                                                                    • bool
                                                                                                                                                    • True on success, false if the value was never set.

                                                                                                                                                    Signature

                                                                                                                                                    1bool Remove(int index)
                                                                                                                                                    

                                                                                                                                                    Concat

                                                                                                                                                    Concatenates the entries from the specified array on to the end of this array.

                                                                                                                                                    Arguments
                                                                                                                                                    • from JSON_Array

                                                                                                                                                    • Array to concat entries from.

                                                                                                                                                    Returns
                                                                                                                                                      • bool
                                                                                                                                                      • True on success, false otherwise.
                                                                                                                                                      Throws
                                                                                                                                                      • If the object being merged is an object or the arrays being merged don’t have the same strict type set, an error will be thrown.

                                                                                                                                                      Signature

                                                                                                                                                      1bool Concat(JSON_Array from)
                                                                                                                                                      

                                                                                                                                                      EnforceType

                                                                                                                                                      Sets the array to enforce a specific type. This will fail if there are any existing elements in the array which are not of the same type.

                                                                                                                                                      Arguments
                                                                                                                                                      • type JSONCellType

                                                                                                                                                      • Type to enforce.

                                                                                                                                                      Returns
                                                                                                                                                        • bool
                                                                                                                                                        • True if the type was enforced successfully, false otherwise.

                                                                                                                                                        Signature

                                                                                                                                                        1bool EnforceType(JSONCellType type)
                                                                                                                                                        

                                                                                                                                                        ImportValues

                                                                                                                                                        Imports a native array’s values into the instance.

                                                                                                                                                        Arguments
                                                                                                                                                        • type JSONCellType

                                                                                                                                                        • Type of native values.

                                                                                                                                                        • values any[]

                                                                                                                                                        • Array of values.

                                                                                                                                                        • size int

                                                                                                                                                        • Size of array.

                                                                                                                                                        Returns
                                                                                                                                                          • bool
                                                                                                                                                          • True on success, false otherwise.

                                                                                                                                                          Signature

                                                                                                                                                          1bool ImportValues(JSONCellType type, any[] values, int size)
                                                                                                                                                          

                                                                                                                                                          ImportStrings

                                                                                                                                                          Imports a native array’s strings into the instance.

                                                                                                                                                          Arguments
                                                                                                                                                          • strings const char[][]

                                                                                                                                                          • Array of strings.

                                                                                                                                                          • size int

                                                                                                                                                          • Size of array.

                                                                                                                                                          Returns
                                                                                                                                                            • bool
                                                                                                                                                            • True on success, false otherwise.

                                                                                                                                                            Signature

                                                                                                                                                            1bool ImportStrings(const char[][] strings, int size)
                                                                                                                                                            

                                                                                                                                                            ExportValues

                                                                                                                                                            Exports the instance’s values into a native array.

                                                                                                                                                            Arguments
                                                                                                                                                            • values any[]

                                                                                                                                                            • Array to export to.

                                                                                                                                                            • max_size int

                                                                                                                                                            • Maximum size of array.

                                                                                                                                                            Signature

                                                                                                                                                            1void ExportValues(any[] values, int max_size)
                                                                                                                                                            

                                                                                                                                                            ExportStrings

                                                                                                                                                            Exports the instance’s strings into a native array.

                                                                                                                                                            Arguments
                                                                                                                                                            • values char[][]

                                                                                                                                                            • Array to export to.

                                                                                                                                                            • max_size int

                                                                                                                                                            • Maximum size of array.

                                                                                                                                                            • max_string_size int

                                                                                                                                                            • Maximum size of array elements.

                                                                                                                                                            Signature

                                                                                                                                                            1void ExportStrings(char[][] values, int max_size, int max_string_size)
                                                                                                                                                            

                                                                                                                                                            ShallowCopy

                                                                                                                                                            For more information, see JSON_Object.ShallowCopy.

                                                                                                                                                            Returns
                                                                                                                                                            • JSON_Array

                                                                                                                                                            Signature

                                                                                                                                                            1JSON_Array ShallowCopy()
                                                                                                                                                            

                                                                                                                                                            DeepCopy

                                                                                                                                                            For more information, see JSON_Object.DeepCopy.

                                                                                                                                                            Returns
                                                                                                                                                            • JSON_Array

                                                                                                                                                            Signature

                                                                                                                                                            1JSON_Array DeepCopy()
                                                                                                                                                            

                                                                                                                                                            JSON_Array

                                                                                                                                                            Creates a new JSON_Array.

                                                                                                                                                            Arguments
                                                                                                                                                            • type JSONCellType

                                                                                                                                                            • The type to enforce for this array, or JSON_Type_Invalid for no enforced type. default: JSON_Type_Invalid

                                                                                                                                                            Returns
                                                                                                                                                              • A new JSON_Array.

                                                                                                                                                              Signature

                                                                                                                                                              1JSON_Array(JSONCellType type = JSON_Type_Invalid)
                                                                                                                                                              

                                                                                                                                                              Global

                                                                                                                                                              Constants

                                                                                                                                                              Constants
                                                                                                                                                              • SM_INT64_SUPPORTED = SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 11 && SOURCEMOD_V_REV >= 6861

                                                                                                                                                              • JSON_NONE = 0

                                                                                                                                                              • Used when no options are desired.

                                                                                                                                                              • JSON_ENCODE_PRETTY = 1 << 0

                                                                                                                                                              • Should encoded output be pretty printed?

                                                                                                                                                              • JSON_DECODE_SINGLE_QUOTES = 1 << 0

                                                                                                                                                              • Should single quote wrapped strings be accepted during decoding?

                                                                                                                                                              • JSON_MERGE_REPLACE = 1 << 0

                                                                                                                                                              • During merge, should existing keys be replaced if they exist in both objects?

                                                                                                                                                              • JSON_MERGE_CLEANUP = 1 << 1

                                                                                                                                                              • During merge, should existing objects be cleaned up if they exist in both objects? (only applies when JSON_MERGE_REPLACE is also set)

                                                                                                                                                              • JSON_INT_BUFFER_SIZE = 12

                                                                                                                                                              • The longest representable integer (“-2147483648”) + NULL terminator

                                                                                                                                                              • JSON_INT64_BUFFER_SIZE = 21

                                                                                                                                                              • The longest representable int64 (“-9223372036854775808”) + NULL terminator

                                                                                                                                                              • JSON_FLOAT_BUFFER_SIZE = 32

                                                                                                                                                              • You may need to change this if you are working with large floats.

                                                                                                                                                              • JSON_BOOL_BUFFER_SIZE = 6

                                                                                                                                                              • “true”|“false” + NULL terminator

                                                                                                                                                              • JSON_NULL_BUFFER_SIZE = 5

                                                                                                                                                              • “null” + NULL terminator

                                                                                                                                                              • JSON_ARRAY_KEY = "is_array"

                                                                                                                                                              • JSON_ENFORCE_TYPE_KEY = "enforce_type"

                                                                                                                                                              • TRIE_SUPPORTS_CONTAINSKEY = SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 11 && SOURCEMOD_V_REV >= 6646

                                                                                                                                                              • For more information, see StringMap.ContainsKey.

                                                                                                                                                              Enums

                                                                                                                                                              JSONCellType

                                                                                                                                                              JSONCellType
                                                                                                                                                                Types of cells within a JSON object
                                                                                                                                                                  Values
                                                                                                                                                                  • JSON_Type_Invalid

                                                                                                                                                                  • -1

                                                                                                                                                                  • JSON_Type_String

                                                                                                                                                                  • 0

                                                                                                                                                                  • JSON_Type_Int

                                                                                                                                                                  • 1

                                                                                                                                                                  • JSON_Type_Int64

                                                                                                                                                                  • 2

                                                                                                                                                                  • JSON_Type_Float

                                                                                                                                                                  • 3

                                                                                                                                                                  • JSON_Type_Bool

                                                                                                                                                                  • 4

                                                                                                                                                                  • JSON_Type_Object

                                                                                                                                                                  • 5

                                                                                                                                                              JSONMetaInfo

                                                                                                                                                              JSONMetaInfo
                                                                                                                                                                Types of metadata a JSON element can have
                                                                                                                                                                  Values
                                                                                                                                                                  • JSON_Meta_Type

                                                                                                                                                                  • 0

                                                                                                                                                                  • JSON_Meta_Size

                                                                                                                                                                  • 1

                                                                                                                                                                  • JSON_Meta_Hidden

                                                                                                                                                                  • 2

                                                                                                                                                                  • JSON_Meta_Index

                                                                                                                                                                  • 3

                                                                                                                                                              Methods

                                                                                                                                                              json_encode_size

                                                                                                                                                              Calculates the buffer size required to store an encoded JSON instance.

                                                                                                                                                              Arguments
                                                                                                                                                              • obj JSON_Object

                                                                                                                                                              • Object to encode.

                                                                                                                                                              • options int

                                                                                                                                                              • Bitwise combination of JSON_ENCODE_* options. default: JSON_NONE

                                                                                                                                                              • depth int

                                                                                                                                                              • The current depth of the encoder. default: 0

                                                                                                                                                              Returns
                                                                                                                                                                • int
                                                                                                                                                                • The required buffer size.

                                                                                                                                                                Signature

                                                                                                                                                                1int json_encode_size(JSON_Object obj, int options = JSON_NONE, int depth = 0)
                                                                                                                                                                

                                                                                                                                                                json_encode

                                                                                                                                                                Encodes a JSON instance into its string representation.

                                                                                                                                                                Arguments
                                                                                                                                                                • obj JSON_Object

                                                                                                                                                                • Object to encode.

                                                                                                                                                                • output char[]

                                                                                                                                                                • String buffer to store output.

                                                                                                                                                                • max_size int

                                                                                                                                                                • Maximum size of string buffer.

                                                                                                                                                                • options int

                                                                                                                                                                • Bitwise combination of JSON_ENCODE_* options. default: JSON_NONE

                                                                                                                                                                • depth int

                                                                                                                                                                • The current depth of the encoder. default: 0

                                                                                                                                                                Signature

                                                                                                                                                                1void json_encode(JSON_Object obj, char[] output, int max_size, int options = JSON_NONE, int depth = 0)
                                                                                                                                                                

                                                                                                                                                                json_decode

                                                                                                                                                                Decodes a JSON string into a JSON instance.

                                                                                                                                                                Arguments
                                                                                                                                                                • buffer const char[]

                                                                                                                                                                • Buffer to decode.

                                                                                                                                                                • options int

                                                                                                                                                                • Bitwise combination of JSON_DECODE_* options. default: JSON_NONE

                                                                                                                                                                • &pos int

                                                                                                                                                                • Current position of the decoder as bytes offset into the buffer. default: 0

                                                                                                                                                                • depth int

                                                                                                                                                                • Current nested depth of the decoder. default: 0

                                                                                                                                                                Returns
                                                                                                                                                                  • JSON_Object
                                                                                                                                                                  • JSON instance or null if decoding failed becase the buffer didn’t contain valid JSON.
                                                                                                                                                                  Throws
                                                                                                                                                                  • If the buffer does not contain valid JSON, an error will be thrown.

                                                                                                                                                                  Signature

                                                                                                                                                                  1JSON_Object json_decode(const char[] buffer, int options = JSON_NONE, int &pos = 0, int depth = 0)
                                                                                                                                                                  

                                                                                                                                                                  json_write_to_file

                                                                                                                                                                  Encodes the object with the options provided and writes the output to the file at the path specified.

                                                                                                                                                                  Arguments
                                                                                                                                                                  • obj JSON_Object

                                                                                                                                                                  • Object to encode/write to file.

                                                                                                                                                                  • path const char[]

                                                                                                                                                                  • Path of file to write to.

                                                                                                                                                                  • options int

                                                                                                                                                                  • Options to pass to json_encode. default: JSON_NONE

                                                                                                                                                                  Returns
                                                                                                                                                                    • bool
                                                                                                                                                                    • True on success, false otherwise.

                                                                                                                                                                    Signature

                                                                                                                                                                    1bool json_write_to_file(JSON_Object obj, const char[] path, int options = JSON_NONE)
                                                                                                                                                                    

                                                                                                                                                                    json_read_from_file

                                                                                                                                                                    Reads and decodes the contents of a JSON file.

                                                                                                                                                                    Arguments
                                                                                                                                                                    • path const char[]

                                                                                                                                                                    • Path of file to read from.

                                                                                                                                                                    • options int

                                                                                                                                                                    • Options to pass to json_decode. default: JSON_NONE

                                                                                                                                                                    Returns
                                                                                                                                                                      • JSON_Object
                                                                                                                                                                      • The decoded object on success, null otherwise.

                                                                                                                                                                      Signature

                                                                                                                                                                      1JSON_Object json_read_from_file(const char[] path, int options = JSON_NONE)
                                                                                                                                                                      

                                                                                                                                                                      json_copy_shallow

                                                                                                                                                                      Creates a shallow copy of the specified object.

                                                                                                                                                                      Arguments
                                                                                                                                                                      • obj JSON_Object

                                                                                                                                                                      • Object to copy.

                                                                                                                                                                      Returns
                                                                                                                                                                        • JSON_Object
                                                                                                                                                                        • A shallow copy of the specified object.

                                                                                                                                                                        Signature

                                                                                                                                                                        1JSON_Object json_copy_shallow(JSON_Object obj)
                                                                                                                                                                        

                                                                                                                                                                        json_copy_deep

                                                                                                                                                                        Creates a deep copy of the specified object.

                                                                                                                                                                        Arguments
                                                                                                                                                                        • obj JSON_Object

                                                                                                                                                                        • Object to copy.

                                                                                                                                                                        Returns
                                                                                                                                                                          • JSON_Object
                                                                                                                                                                          • A deep copy of the specified object.

                                                                                                                                                                          Signature

                                                                                                                                                                          1JSON_Object json_copy_deep(JSON_Object obj)
                                                                                                                                                                          

                                                                                                                                                                          json_cleanup

                                                                                                                                                                          Recursively cleans up the instance and any instances stored within.

                                                                                                                                                                          Arguments
                                                                                                                                                                          • obj JSON_Object

                                                                                                                                                                          • Object to clean up.

                                                                                                                                                                          Signature

                                                                                                                                                                          1void json_cleanup(JSON_Object obj)
                                                                                                                                                                          

                                                                                                                                                                          json_cleanup_and_delete

                                                                                                                                                                          Cleans up an object and sets the passed variable to null.

                                                                                                                                                                          Arguments
                                                                                                                                                                          • &obj JSON_Object

                                                                                                                                                                          • Object to clean up.

                                                                                                                                                                          Signature

                                                                                                                                                                          1void json_cleanup_and_delete(JSON_Object &obj)
                                                                                                                                                                          

                                                                                                                                                                          json_get_last_error

                                                                                                                                                                          Retrieves the last error encountered and stores it in the buffer provided.

                                                                                                                                                                          Arguments
                                                                                                                                                                          • buffer char[]

                                                                                                                                                                          • String buffer.

                                                                                                                                                                          • max_size int

                                                                                                                                                                          • Maximum size of string buffer.

                                                                                                                                                                          Returns
                                                                                                                                                                            • bool
                                                                                                                                                                            • True if the error was copied successfuly, false otherwise.

                                                                                                                                                                            Signature

                                                                                                                                                                            1bool json_get_last_error(char[] buffer, int max_size)