Using JSON in Caché
Quick Reference for Dynamic Entity Methods
[Home] [Back] 
InterSystems: The power behind what matters   
Class Reference   
Search:    

This section provides an overview and references for each of the available dynamic entity methods. Dynamic entities are instances of %Library.DynamicObject or %Library.DynamicArray, both of which extend %Library.DynamicAbstractObject. Each listing in this chapter includes a link to the appropriate online class reference documentation.

Method Details
This section lists all available dynamic entity methods, briefly describing each one and providing links to further information. All methods are available for both objects and arrays, with the exception of %Push() and %Pop(), which apply only to arrays.
%FromJSON()
Given a JSON source, parse the source and return an object of datatype %DynamicAbstractObject containing the parsed JSON. If an error occurs during parsing, an exception will be thrown. See Converting Dynamic Entities to and from JSON for details and examples.
   classmethod %FromJSON(str) as %DynamicAbstractObject
parameters:
see also: %ToJSON(), Serializing Large Dynamic Entities to Streams
class reference: %DynamicAbstractObject.%FromJSON()
%Get()
Given a valid object key or array index, returns the value. If the value does not exist, a null string "" is returned. See Using %Set(), %Get(), and %Remove() for details and examples.
   method %Get(key) as %CacheString
parameters:
see also: %Set(), %Remove(), %Pop()
class reference: %DynamicObject.%Get() and %DynamicArray.%Get()
%GetIterator()
Returns a %Iterator object allowing iteration over all members of a dynamic entity. See Iterating over a Dynamic Entity with %GetNext() for details and examples.
   method %GetIterator() as %Iterator.AbstractIterator
see also: %GetNext()
class reference: %DynamicObject.%GetIterator(), %DynamicArray.%GetIterator(), %Iterator.Object, %Iterator.Array
%GetNext()
This is a method of the %Iterator object returned by %GetIterator(). It advances the iterator and returns true if the iterator is positioned on a valid element, false if it is beyond the last element. The key and value arguments return values for a valid element at the current iterator position. See Iterating over a Dynamic Entity with %GetNext() for details and examples.
   method getNext(Output key, Output value) as %Integer
parameters:
see also: %GetIterator()
class reference: %Iterator.Object.%GetNext() and %Iterator.Array.%GetNext()
%GetTypeOf()
Given a valid object key or array index, returns a string indicating the datatype of the value. See Working with Datatypes for details and examples.
   method %GetTypeOf(key) as %String
parameters:
return values:
One of the following strings will be returned:
see also: %IsDefined()
class reference: %DynamicAbstractObject.%GetTypeOf()
%IsDefined()
Tests if the item specified by key is defined within an object. Returns false if the item is unassigned or does not exist. See Using %IsDefined() to Test for Valid Values for details and examples.
   method %IsDefined(key) as %Boolean
parameters:
see also: Resolving Null, Empty String, and Unassigned Values
class reference: %DynamicObject.%IsDefined() and %DynamicArray.%IsDefined()
%Pop()
Returns the value of the last member of the array. The value is then removed from the array. If the array is already empty, the method returns the empty string, "". See Using %Push and %Pop with Dynamic Arrays for details and examples.
   method %Pop() as %CacheString
see also: %Push(), %Get(), %Remove(), Resolving Null, Empty String, and Unassigned Values
class reference: %DynamicArray.%Pop()
%Push()
Given a new value, append it to the end of the current array, increasing the length of the array. value Returns An oref referencing the current modified array, allowing calls to %Push() to be chained. See Using %Push and %Pop with Dynamic Arrays for details and examples.
   method %Push(value, type) as %DynamicAbstractObject
parameters:
see also: %Pop(), %Set(), Overriding a Default Datatype with %Set() or %Push(), Method Chaining
class reference: %DynamicArray.%Push()
%Remove()
Removes the specified element from a dynamic object or array, and returns the value of the removed element. If the value of the element is an embedded dynamic object or array, all subordinate nodes are removed as well. In a dynamic array, all elements following the removed element will have their subscript position decremented by 1. See Using %Set(), %Get(), and %Remove() for details and examples.
   method %Remove(key) as %DynamicAbstractObject
parameters:
see also: %Set(), %Get(), %Pop()
class reference: %DynamicObject.%Remove() and %DynamicArray.%Remove()
%Set()
Create a new value or update an existing value. Returns a reference to the modified array, allowing calls to %Set() to be nested. See Using %Set(), %Get(), and %Remove() for details and examples.
   method %Set(key, value, type) as %DynamicAbstractObject
parameters:
see also: %Get(), %Remove(), %Push(), Overriding a Default Datatype with %Set() or %Push(), Method Chaining
class reference: %DynamicObject.%Set() and %DynamicArray.%Set()
%Size()
Returns an integer showing the size of a dynamic object or array. In the case of an array, the size includes unassigned entries within the array. In the case of an object, the size only includes elements that have assigned values. See Sparse Array Iteration with %Size() for details and examples.
   method %Size() as %Integer
see also: %GetNext()
class reference: %DynamicAbstractObject.%Size()
%ToJSON()
Converts an instance of %DynamicAbstractObject. into a JSON string. See Converting Dynamic Entities to and from JSON for details and examples.
   method %ToJSON(outstrm As %Stream.Object) as %String
parameters:
see also: %FromJSON()
class reference: %DynamicAbstractObject.%ToJSON()