THRIFT-3748 Node.js Deserialization of lists of lists is broken

This closes #957
diff --git a/lib/nodejs/lib/thrift/json_protocol.js b/lib/nodejs/lib/thrift/json_protocol.js
index 2e0d29a..f31e3b2 100644
--- a/lib/nodejs/lib/thrift/json_protocol.js
+++ b/lib/nodejs/lib/thrift/json_protocol.js
@@ -634,7 +634,12 @@
 
 /** Deserializes the end of a list. */
 TJSONProtocol.prototype.readListEnd = function() {
-  this.readFieldEnd();
+  var pos = this.rpos.pop() - 2;
+  var st = this.rstack;
+  st.pop();
+  if (st instanceof Array && st.length > pos && st[pos].length > 0) {
+    st.push(st[pos].shift());
+  }
 };
 
 /**
diff --git a/lib/nodejs/test/deep-constructor.test.js b/lib/nodejs/test/deep-constructor.test.js
index 8dd29ee..2caeb82 100644
--- a/lib/nodejs/test/deep-constructor.test.js
+++ b/lib/nodejs/test/deep-constructor.test.js
@@ -91,9 +91,22 @@
           DB: new ttypes.Simple({value: 'k'})
         }
       ]
-    }
-  }
-  );
+    },
+
+    list_of_list_field: [
+      ['l00', 'l01', 'l02'],
+      ['l10', 'l11', 'l12'],
+      ['l20', 'l21', 'l22'],
+    ],
+
+    list_of_list_of_list_field: [
+      [['m000', 'm001', 'm002'], ['m010', 'm011', 'm012'], ['m020', 'm021', 'm022']],
+      [['m100', 'm101', 'm102'], ['m110', 'm111', 'm112'], ['m120', 'm121', 'm122']],
+      [['m200', 'm201', 'm202'], ['m210', 'm211', 'm212'], ['m220', 'm221', 'm222']],
+    ],
+
+
+  });
 }
 
 
@@ -138,7 +151,20 @@
           DB: {value: 'k'}
         }
       ]
-    }
+    },
+
+    list_of_list_field: [
+      ['l00', 'l01', 'l02'],
+      ['l10', 'l11', 'l12'],
+      ['l20', 'l21', 'l22'],
+    ],
+
+    list_of_list_of_list_field: [
+      [['m000', 'm001', 'm002'], ['m010', 'm011', 'm012'], ['m020', 'm021', 'm022']],
+      [['m100', 'm101', 'm102'], ['m110', 'm111', 'm112'], ['m120', 'm121', 'm122']],
+      [['m200', 'm201', 'm202'], ['m210', 'm211', 'm212'], ['m220', 'm221', 'm222']],
+    ],
+
   };
 }
 
@@ -155,6 +181,45 @@
     assert.equals(obj.struct_nested_containers_field[0][0].C[1].value, 'i');
     assert.equals(obj.struct_nested_containers_field2.D[0].DA.value, 'j');
     assert.equals(obj.struct_nested_containers_field2.D[1].DB.value, 'k');
+    assert.equals(obj.list_of_list_field[0][0], 'l00');
+    assert.equals(obj.list_of_list_field[0][1], 'l01');
+    assert.equals(obj.list_of_list_field[0][2], 'l02');
+    assert.equals(obj.list_of_list_field[1][0], 'l10');
+    assert.equals(obj.list_of_list_field[1][1], 'l11');
+    assert.equals(obj.list_of_list_field[1][2], 'l12');
+    assert.equals(obj.list_of_list_field[2][0], 'l20');
+    assert.equals(obj.list_of_list_field[2][1], 'l21');
+    assert.equals(obj.list_of_list_field[2][2], 'l22');
+
+    assert.equals(obj.list_of_list_of_list_field[0][0][0], 'm000');
+    assert.equals(obj.list_of_list_of_list_field[0][0][1], 'm001');
+    assert.equals(obj.list_of_list_of_list_field[0][0][2], 'm002');
+    assert.equals(obj.list_of_list_of_list_field[0][1][0], 'm010');
+    assert.equals(obj.list_of_list_of_list_field[0][1][1], 'm011');
+    assert.equals(obj.list_of_list_of_list_field[0][1][2], 'm012');
+    assert.equals(obj.list_of_list_of_list_field[0][2][0], 'm020');
+    assert.equals(obj.list_of_list_of_list_field[0][2][1], 'm021');
+    assert.equals(obj.list_of_list_of_list_field[0][2][2], 'm022');
+
+    assert.equals(obj.list_of_list_of_list_field[1][0][0], 'm100');
+    assert.equals(obj.list_of_list_of_list_field[1][0][1], 'm101');
+    assert.equals(obj.list_of_list_of_list_field[1][0][2], 'm102');
+    assert.equals(obj.list_of_list_of_list_field[1][1][0], 'm110');
+    assert.equals(obj.list_of_list_of_list_field[1][1][1], 'm111');
+    assert.equals(obj.list_of_list_of_list_field[1][1][2], 'm112');
+    assert.equals(obj.list_of_list_of_list_field[1][2][0], 'm120');
+    assert.equals(obj.list_of_list_of_list_field[1][2][1], 'm121');
+    assert.equals(obj.list_of_list_of_list_field[1][2][2], 'm122');
+
+    assert.equals(obj.list_of_list_of_list_field[2][0][0], 'm200');
+    assert.equals(obj.list_of_list_of_list_field[2][0][1], 'm201');
+    assert.equals(obj.list_of_list_of_list_field[2][0][2], 'm202');
+    assert.equals(obj.list_of_list_of_list_field[2][1][0], 'm210');
+    assert.equals(obj.list_of_list_of_list_field[2][1][1], 'm211');
+    assert.equals(obj.list_of_list_of_list_field[2][1][2], 'm212');
+    assert.equals(obj.list_of_list_of_list_field[2][2][0], 'm220');
+    assert.equals(obj.list_of_list_of_list_field[2][2][1], 'm221');
+    assert.equals(obj.list_of_list_of_list_field[2][2][2], 'm222');
 }
 
 function createTestCases(serialize, deserialize) {
diff --git a/test/JsDeepConstructorTest.thrift b/test/JsDeepConstructorTest.thrift
index c2e23af..ef5126f 100644
--- a/test/JsDeepConstructorTest.thrift
+++ b/test/JsDeepConstructorTest.thrift
@@ -9,6 +9,8 @@
   4: map<string,Simple> struct_map_field
   5: list<set<map<string,list<Simple>>>> struct_nested_containers_field
   6: map<string, list<map<string,Simple>> > struct_nested_containers_field2
+  7: list<list<string>> list_of_list_field
+  8: list<list<list<string>>> list_of_list_of_list_field
 }
 
 struct ComplexList {