util.JSONObject.getType
Returns the type of a JSON object element.
Syntax
util.JSONObject.getType(
name STRING )
RETURNS STRING
- name is the name of the element.
Usage
The getType()
method returns the JSON data type name
corresponding to the element name passed as parameter.
This method can be used along with the name()
and
getLength()
methods, to read the entries of a JSON object.
Possible values returned by this method are:
NUMBER
: A numeric value.STRING
: A string value delimited by double quotes.BOOLEAN
: A boolean value (true/false)NULL
: A non-existing element.OBJECT
: A structured object.ARRAY
: An ordered list of elements.
Example
IMPORT util
MAIN
DEFINE obj util.JSONObject
LET obj = util.JSONObject.create()
CALL obj.put("id", 8723)
DISPLAY obj.getType("id") -- NUMBER
CALL obj.put("name", "Brando")
DISPLAY obj.getType("name") -- STRING
DISPLAY obj.getType("undef") -- NULL
END MAIN