Result = JSONType(JSONValue)
Returns the type of the given JSON value.


JSONValue The JSON value.

Return value

It can be one of the following:

The value represents the JSON literal null.
The value contains a string. GetJSONString() can be used to read the string.
The value contains a number. GetJSONDouble(), GetJSONFloat(), GetJSONInteger() or GetJSONQuad() can be used to read the number.
The value contains a boolean. GetJSONBoolean() can be used to read the value.
The value contains an array of JSON elements. JSONArraySize() returns the size of the array. GetJSONElement() can be used to get a specific array element. AddJSONElement(), RemoveJSONElement(), ResizeJSONElements() or ClearJSONElements() can be used to modify the array.
The value contains an object (a set of key/value pairs). JSONObjectSize() returns the number of menbers in the object. GetJSONMember() returns a specific member value. ExamineJSONMembers() can be used to examine the member values. AddJSONMember(), RemoveJSONMember() or ClearJSONMembers() can be used to modify the object.


  ; A procedure that accepts any JSON value and returns a string
  Procedure.s GetAnyValue(Value)
    Select JSONType(Value)
      Case #PB_JSON_Null:    ProcedureReturn "null"
      Case #PB_JSON_String:  ProcedureReturn GetJSONString(Value)
      Case #PB_JSON_Number:  ProcedureReturn StrD(GetJSONDouble(Value))    
      Case #PB_JSON_Boolean: ProcedureReturn Str(GetJSONBoolean(Value))
      Case #PB_JSON_Array:   ProcedureReturn "array"
      Case #PB_JSON_Object:  ProcedureReturn "object"
  ParseJSON(0, "[1, 2, true, null, " + Chr(34) + "hello" + Chr(34) + "]")
  For i = 0 To JSONArraySize(JSONValue(0)) - 1
    Debug GetAnyValue(GetJSONElement(JSONValue(0), i))
  Next i

See Also

JSONValue(), SetJSONArray(), SetJSONBoolean(), SetJSONDouble(), SetJSONFloat(), SetJSONInteger(), SetJSONNull(), SetJSONObject(), SetJSONString(), SetJSONQuad()

Supported OS


<- JSONObjectSize() - Json Index - JSONValue() ->