jsValueType

Returns the JSON type of a value associated with a key in a JSON container.

Syntax:

jsValueType ( container-handle , key-name, [, key-delimiter] )

Parameters:

(s) container-handle: extender JSON handle.

(s) key-name: name of an existing key including the full JSON path to the key.

(s) key-delimiter: [optional] single character used between key names in any path included in the key-name parameter (defaults to a dot character(".")).

Returns:

(i) integer indicating the JSON type of a value (see table below.)

 

This function is almost identical to jsValueGet except that it retrieves the JSON type of value of a key/value pair contained within the passed in JSON object, one of its child objects, or array contained within the object or sub object.

 

Container-Handle

The unique identifier returned from a call to the jsParse, jsObjNew, jsValueGet functions, or by accessing WIL map element returned by the jsConMap function. The key-name with path must be a path to a key in this object or one of  its child containers. 

  

Key-Name

The key name of a simple key/value pair, an array key name with bracketed index, or an empty bracket with bracketed index for an anonymous array. The name must include JSON path information when the pair exists in a child container and a bracketed index number when targeting an element of an array. See the About JSON Paths topic for detailed description of JSON paths.

 

Important:

 

Key-Delimiter

An optional parameter that must be a single character used between key specifications in the JSON path. The default value is a dot ("."). The space(' '), backslash('\'), single-quote("'"), double-quote('"'), dollar-sign("$"), left-bracket("["), right-bracket("]") and grave-accent("`") cannot be used as delimiters.   

  

Return-Values

  

Map Key Value

Meaning

@JsonNull (1)

An empty value represented by the text string "null".

@JsonBool (2)

An true or false value represented but the text string "true" or "false".

@JsonNum (4)

A 32-bit integer, 64-bit integer, or floating point number.

@JsonStr (8)

A text string.

@JsonArr (16)

An array represented by an extender container handle..

@JsonObj (32)

A JSON object represented by an extender container handle.

  

Example:
  ; JSON data as a multi-line string constant.
  JsonData = $"{
    "dependencies":: {
      "Microsoft.NETCore.UniversalWindowsPlatform":: "5.2.2",
      "Microsoft.Toolkit.Uwp.Notifications":: "1.1.0",
      "QueryString.NET":: "1.0.0"
    },
    "frameworks":: {
      "uap10.0":: {}
    },
    "runtimes":: {
      "win10-arm":: {},
      "win10-arm-aot":: {},
      "win10-x86":: {},
      "win10-x86-aot":: {},
      "win10-x64":: {},
      "win10-x64-aot":: {}
    }
  }$"
  
  AddExtender('ilcjs44i.dll', 0, 'ilcjs64i.dll')
  
  ; Create an JSON object.
  Object = jsParse(JsonData )
  ; Get the type for all values in the JSON data.
  Key = ''
  ; Let the extender build the path.
  Paths = jsKeyPaths(Object, Key)
  ; Get the key's value.
  ObjCnt = 0
  ForEach Path In Paths
     If jsValueType(Object, Path) == @JsonObj Then ObjCnt +=1
  Next
  ; Do something with the value.
  Message('Nested Object Count', 'Number of nested object: ':ObjCnt)
  jsConClose()
  
See Also:

jsParse,  jsConNewjsValueTypejsKeyPaths