ENUM JSON_Token
  JSON_TOKEN_TAB = 09
  JSON_TOKEN_LF = 10
  JSON_TOKEN_CR = 13
  JSON_TOKEN_SPACE = 32
  JSON_TOKEN_DOUBLE_QUOTE = 34
  JSON_TOKEN_COMMA = 44
  JSON_TOKEN_SLASH = 47
  JSON_TOKEN_COLON = 58
  JSON_TOKEN_ARRAY_OPEN = 91
  JSON_TOKEN_ESCAPE = 92
  JSON_TOKEN_ARRAY_CLOSE = 93
  JSON_TOKEN_OBJECT_OPEN = 123
  JSON_TOKEN_OBJECT_CLOSE = 125
END ENUM

ENUM JSON_Type
  JSON_TYPE_NULL
  JSON_TYPE_BOOLEAN
  JSON_TYPE_NUMERIC
  JSON_TYPE_STRING
  JSON_TYPE_ARRAY
  JSON_TYPE_OBJECT
  JSON_TYPE_ERROR
END ENUM

TYPE JSON_Value
  ValueType AS JSON_Type
  RawContent AS STRING
END TYPE

TYPE JSON_Object
  MemberCount AS ULONG
  RawContent AS STRING
END TYPE

TYPE JSON_Member
  Name AS STRING
  Value AS JSON_Value
END TYPE

TYPE JSON_Array
  ValueCount AS ULONG
  RawContent AS STRING
END TYPE

'JSON Parsing
DECLARE SUB JSON_ParseArray(ArrayJSON AS JSON_Array, ArrayValues() AS JSON_Value)
DECLARE SUB JSON_CountValues(ArrayJSON AS JSON_Array)
DECLARE FUNCTION JSON_GetValueIndex(ArrayValues() AS JSON_Value, TargetValue AS JSON_Value) AS LONG
DECLARE SUB JSON_ParseObject(oJSON AS JSON_Object, ArrayMembers() AS JSON_Member)
DECLARE SUB JSON_CountMembers(oJSON AS JSON_Object)
DECLARE FUNCTION JSON_GetMemberValue(ArrayMembers() AS JSON_Member, MemberName AS STRING) AS STRING
DECLARE FUNCTION JSON_GetMemberIndex(ArrayMembers() AS JSON_Member, MemberName AS STRING) AS LONG
DECLARE FUNCTION JSON_GetType(value AS STRING) AS ULONG
DECLARE FUNCTION JSON_ParseString(RawString AS STRING) AS STRING

'JSON Generation
DECLARE FUNCTION JSON_GenerateObject (ArrayMembers() AS JSON_member) AS STRING
DECLARE FUNCTION JSON_GenerateArray (ArrayValues() AS JSON_Value) AS STRING
DECLARE FUNCTION JSON_GenerateString (Content AS STRING) AS STRING

'JSON Array Operations
DECLARE SUB JSON_AddValue(ArrayValues AS JSON_Array, NewValue AS JSON_Value, ValueIndex AS ULONG = 0)
DECLARE SUB JSON_DeleteValue(ArrayValues AS JSON_Array, ValueIndex AS ULONG)
DECLARE SUB JSON_UpdateValue(ArrayValues AS JSON_Array, NewValue AS JSON_Value, ValueIndex AS ULONG)

'JSON Objects Operations
DECLARE SUB JSON_AddMember (oJSON AS JSON_Object, NewMember AS JSON_Member, Index AS ULONG = 0)
DECLARE SUB JSON_UpdateMember (oJSON AS JSON_Object, UpdatedMember AS JSON_Member)
DECLARE SUB JSON_DeleteMember (oJSON AS JSON_Object, MemberName AS STRING)
DECLARE SUB JSON_PreserveMembers (oJSON AS JSON_Object, ArrayMembers() AS JSON_Member)
DECLARE SUB JSON_SetMemberValue (ArrayMembers() AS JSON_Member, MemberName AS STRING, ValueContent AS STRING, ValueType AS JSON_Type = JSON_TYPE_STRING)
DECLARE SUB JSON_FillObject(oJSON AS JSON_Object, MemberName AS STRING, MemberValue AS STRING)
DECLARE SUB JSON_FillArray(ArrayValues AS JSON_Array, ValueContent AS STRING)

#DEFINE JSON_Log(LogAction) (SHELL("echo " + LogAction + " >> ..\logs\logfile.txt"))
