@@ -123,8 +123,8 @@ public int readArrayBegin() {
123123 throw new MessageTypeException ("Expected array but got not array value" );
124124 }
125125 ArrayValue a = v .asArrayValue ();
126- values [stack .getDepth ()] = a .getElementArray ();
127126 stack .pushArray (a .size ());
127+ values [stack .getDepth ()] = a .getElementArray ();
128128 return a .size ();
129129 }
130130
@@ -153,8 +153,8 @@ public int readMapBegin() {
153153 throw new MessageTypeException ("Expected array but got not array value" );
154154 }
155155 MapValue m = v .asMapValue ();
156- values [stack .getDepth ()] = m .getKeyValueArray ();
157156 stack .pushMap (m .size ());
157+ values [stack .getDepth ()] = m .getKeyValueArray ();
158158 return m .size ();
159159 }
160160
@@ -186,7 +186,7 @@ private Value getTop() {
186186 return (Value ) values [0 ];
187187 }
188188 Value [] array = (Value []) values [stack .getDepth ()];
189- return array [stack .getTopCount ()];
189+ return array [array . length - stack .getTopCount ()];
190190 }
191191
192192 @ Override
@@ -209,14 +209,14 @@ protected void readValue(Unconverter uc) {
209209 if (v .isArray ()) {
210210 ArrayValue a = v .asArrayValue ();
211211 uc .writeArrayBegin (a .size ());
212- values [stack .getDepth ()] = a .getElementArray ();
213212 stack .pushArray (a .size ());
213+ values [stack .getDepth ()] = a .getElementArray ();
214214
215215 } else if (v .isMap ()) {
216216 MapValue m = v .asMapValue ();
217217 uc .writeMapBegin (m .size ());
218- values [stack .getDepth ()] = m .getKeyValueArray ();
219218 stack .pushMap (m .size ());
219+ values [stack .getDepth ()] = m .getKeyValueArray ();
220220
221221 } else {
222222 uc .write (v );
@@ -253,13 +253,13 @@ public void skip() {
253253 while (true ) {
254254 if (v .isArray ()) {
255255 ArrayValue a = v .asArrayValue ();
256- values [stack .getDepth ()] = a .getElementArray ();
257256 stack .pushArray (a .size ());
257+ values [stack .getDepth ()] = a .getElementArray ();
258258
259259 } else if (v .isMap ()) {
260260 MapValue m = v .asMapValue ();
261- values [stack .getDepth ()] = m .getKeyValueArray ();
262261 stack .pushMap (m .size ());
262+ values [stack .getDepth ()] = m .getKeyValueArray ();
263263
264264 } else {
265265 stack .reduceCount ();
0 commit comments