JsonCircularReference class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
No edit summary
m (remove paragraph)
 
(21 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<!-- JsonCircularReference class -->
<!-- JsonCircularReference class -->
__NOTOC__
__NOTOC__
The <var>JsonCircularReference</var> exception class indicates that the <var>[[Daemon_class|JsonCircularReference]]</var> class <var>[[New_(Daemon_constructor)|New]]</var> constructor was invoked, but there were no daemon threads available to service the object.
<var>JsonCircularReference</var> [[Exceptions|exceptions]] are thrown by the <var>[[Stringify (Json function)|Stringify]]</var> function in the <var>[[Json class|Json]]</var> class if the <var>Json</var> object leads to a [[Json class#Circular references|circular reference]]
 
To produce a <var>JsonCircularReference</var> exception for yourself, you typically use a <var class="product">SOUL</var> <var>[[Exceptions#Throwing exceptions|Throw]]</var> statement with a <var>JsonCircularReference</var> <var>[[New_(JsonCircularReference_constructor)|New]]</var> constructor.  For example, the following statement throws a <var>JsonCircularReference</var> exception:
The <var>JsonCircularReference</var> class, like the <var>Json</var> class, is available as of <var class="product">Model 204</var> 7.6.
<p class="code">throw %(JsonCircularReference):new
</p>


==The JsonCircularReference methods==
==The JsonCircularReference methods==
Line 16: Line 13:
<li>[[JsonCircularReference methods syntax]] is a single page that contains the syntax diagrams of all the methods in the class. </li>
<li>[[JsonCircularReference methods syntax]] is a single page that contains the syntax diagrams of all the methods in the class. </li>
</ul>
</ul>


==New constructor==
==New constructor==
Line 27: Line 23:


====Syntax terms====
====Syntax terms====
<table class="syntaxTable">
<table>
 
<tr><th>%JsonCircularReference </th>
<tr><th>%JsonCircularReference </th>
<td>A reference to an instance of a <var>JsonCircularReference</var> object.
<td>A reference to an instance of a <var>JsonCircularReference</var> object.
</td></tr>
</td></tr>


<tr><th><var>[%(JsonCircularReference):]</var></th><td>The class name in parentheses denotes a <var>[[Notation conventions for methods#Constructors|Constructor]]</var>. See [[#Usage notes|Usage notes]], below, for more information about invoking a <var>JsonCircularReference</var> <var>Constructor</var>.</td></tr>
<tr><th><var>[%(JsonCircularReference):]</var></th>
<td>The class name in parentheses denotes a <var>[[Notation conventions for methods#Constructors|Constructor]]</var>.</td></tr>
</table>
</table>


===Usage notes===
===Usage notes===
<ul>
<p>
<li>As described in [[Object variables#Using New or other Constructors|Using New or other Constructors]], <var>New</var> can be invoked with no object, with an explicit class name, or with an object variable in the class, even if that object is <var>Null</var>:
The following example catches a circular reference exception and prints the string where the circular reference occurs.
<p class="code">%nfdaem = new
</p>
 
<p class="code">b                                                     
%nfdaem = %(JsonCircularReference):new
%jsonCircRefError    is object JsonCircularReference   
 
%jsa is object json                                   
%nfdaem = %nfdaem:new
%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>
</p>
</ul>


Running this example results in:
<p class="output">Caught Json Circular Reference Error 
["a",["b",["c",[Circular]]]]
</p>
       
[[Category:System exception classes]]
[[Category:System exception classes]]

Latest revision as of 00:44, 13 May 2015


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

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.

Usage notes

The following example catches a circular reference exception and prints the string where the circular reference occurs.

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

Running this example results in:

Caught Json Circular Reference Error ["a",["b",["c",[Circular]]]]