@@ -65,10 +65,22 @@ public boolean isObject() {
6565 return true ;
6666 }
6767
68- public AbstractObject object () {
68+ public AbstractObject object (boolean strict ) throws AbstractCoercingException {
6969 return this ;
7070 }
7171
72+ public AbstractArray array (boolean strict ) throws AbstractCoercingException {
73+ if (strict )
74+ throw new AbstractCoercingException (Type .ARRAY , Type .OBJECT );
75+ AbstractArray array = new AbstractArray ();
76+ for (int i = 0 ; i < size (); i ++) {
77+ if (!has (String .valueOf (i )))
78+ throw new AbstractCoercingException (Type .ARRAY , this );
79+ array .add (get (String .valueOf (i )));
80+ }
81+ return array ;
82+ }
83+
7284 public AbstractElement get (String key ) {
7385 return entries .get (key );
7486 }
@@ -127,18 +139,6 @@ public int size() {
127139 return entries .size ();
128140 }
129141
130- public AbstractArray array (boolean strict ) throws AbstractCoercingException {
131- if (strict )
132- throw new AbstractCoercingException (Type .ARRAY , Type .OBJECT );
133- AbstractArray array = new AbstractArray ();
134- for (int i = 0 ; i < size (); i ++) {
135- if (!has (String .valueOf (i )))
136- throw new AbstractCoercingException (Type .ARRAY , this );
137- array .add (get (String .valueOf (i )));
138- }
139- return array ;
140- }
141-
142142 public AbstractObject object (String key ) throws AbstractCoercingException {
143143 return query (key , AbstractNull .VALUE ).object ();
144144 }
0 commit comments