JsonCircularReference class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
Line 39: Line 39:


===Usage notes===
===Usage notes===
 
<p class="code">
 
b                                                     
%jsonCircRefError    is object JsonCircularReference   
%jsa is object json                                   
%jsb is object json                                   
%jsc is object json                                   
                                                       
%jsa = array('a')                                     
%jsb = array('b')                                     
%jsc = array('c')                                     
%jsa:add(%jsb)                                         
%jsb:add(%jsc)                                         
%jsc:add(%jsa)                                         
                                                       
try                                                   
print %jsa:stringify                                   
  catch JsonCircularReference to %jsonCircRefError   
    print 'Caught Json Circular Reference Error'     
    print %jsa:tostring                               
end try                                               
end                                                   
</p>
[[Category:System exception classes]]
[[Category:System exception classes]]

Revision as of 18:39, 1 May 2015

JsonCircularReference exceptions are thrown by the Stringify function in the Json class if the Json object leads to a circular reference.

To produce a JsonCircularReference exception for yourself, you typically use a SOUL Throw statement with a JsonCircularReference New constructor. This statement must be issued from within a method, and it can only be caught by the code that calls the method. For example, the following statement throws a JsonCircularReference exception:

throw %(JsonCircularReference):new

Remember that you catch an exception with the Catch statement; if an exception condition occurs outside a Catch for it, the request is canceled.

The JsonCircularReference class, like the Json class is available as of Model 204 7.6.

The JsonCircularReference methods

The following are the available JsonCircularReference class methods.

MethodDescription
NewCreate a new JsonCircularReference object

The methods in the class are described in the subsections that follow. In addition:


New constructor

Create a new JsonCircularReference object (JsonCircularReference class)

This Constructor generates an instance of a JsonCircularReference exception. The New method format is as follows:

Syntax

%jsonCircularReference = [%(JsonCircularReference):]New

Syntax terms

%JsonCircularReference A reference to an instance of a JsonCircularReference object.
[%(JsonCircularReference):]The class name in parentheses denotes a Constructor. See Usage notes, below, for more information about invoking a JsonCircularReference Constructor.

Usage notes

b %jsonCircRefError is object JsonCircularReference %jsa is object json %jsb is object json %jsc is object json %jsa = array('a') %jsb = array('b') %jsc = array('c') %jsa:add(%jsb) %jsb:add(%jsc) %jsc:add(%jsa) try print %jsa:stringify catch JsonCircularReference to %jsonCircRefError print 'Caught Json Circular Reference Error' print %jsa:tostring end try end