jsObjNew

Creates an empty JSON object.

Syntax:

jsObjNew ( )

Returns:

(a) object-handle: A JSON extender handle to an empty JSON object.

 

JsObjNew creates and returns a JSON extender object handle that can be used as the root object of a new JSON object tree or added to another object as the value part of a JSON key/value pair.

  

Example:
  AddExtender('c:\projects\json\debug\ilcjs44i.dll', 0, 'ilcjs64i.dll')
  
  ; Start a new JSON.
  Object = jsObjNew()
  
  ; Add a string pair to the new object.
  jsValueAdd(Object, 'first key', 'helo world', @JsonStr)
  
  ; Add a sub-object with a key.
  Sub = jsObjNew()
  jsValueAdd(Sub, 'second key', 'under world', @JsonStr)
  jsValueAdd(Object, 'sub-key', Sub, @JsonObj)
  
  ; Check if it worked.
  Path = jsKeyPaths(Object, 'second key')
  ; Check the assumption of one pair with the name.
  Terminate(1!=ArrInfo(Path, 1), 'Error', 'None or more than one pair with key name.')
  TestVal = jsValueGet(Object, Path[0])
  Message('Sub-key Value', 'The "second Key" value is "':TestVal:'"')
  
  jsObjClose()
  
See Also:

jsValueAdd, jsValueGet, jsKeyPaths