json.bi

File libs/json.bi from the latest check-in


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 USHORT
  RawContent AS STRING
END TYPE

TYPE JSON_Object
  MemberCount AS UINTEGER
  RawContent AS STRING
END TYPE

TYPE JSON_Member
  Name AS STRING
  Value AS JSON_Value
END TYPE

TYPE JSON_Array
  ValueCount AS UINTEGER
  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 SUB JSON_ParseObject (oJSON AS JSON_Object, ArrayMembers() AS JSON_Member)
DECLARE SUB JSON_CountMembers (oJSON AS JSON_Object)
DECLARE FUNCTION JSON_GetType (value AS STRING) AS USHORT
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 Objects Operations
DECLARE SUB JSON_AddMember (oJSON AS JSON_Object, NewMember AS JSON_Member, Index AS UINTEGER = 0)
DECLARE SUB JSON_UpdateMember (oJSON AS JSON_Object, UpdatedMember AS JSON_Member)
DECLARE SUB JSON_DeleteMember (oJSON AS JSON_Object, MemberName AS STRING)

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