internal static ExpandoObject ReadExpandoObject(JsonReader reader, JsonDeserializeHandler handler) { if (reader.ReadNullOrObjLeft()) { return(null); } ExpandoObject obj = new ExpandoObject(); var dic = (IDictionary <string, object>)obj; int moveNext = 1; while (moveNext-- > 0) { var key = PrimitiveResolve.ReadEscapeString(reader, handler); reader.ReadColon(); var value = PrimitiveResolve.ReadObject(reader, handler); dic.Add(key, value); if (reader.ReadBoolComma()) { moveNext++; } } reader.ReadObjRight(); return(obj); }
internal static DataTable ReadDataTable(JsonReader reader, JsonDeserializeHandler handler) { //[{ \"Id\":1 , \"Name\":\"ss\" }] if (reader.ReadNullOrArrayLeft()) { return(null); } DataTable dt = new DataTable(); int moveNext = 1; while (moveNext-- > 0) { reader.ReadObjLeft(); DataRow dr = dt.NewRow(); int move = 1; while (move-- > 0) { string columnName = PrimitiveResolve.ReadEscapeString(reader, handler); reader.ReadColon(); DataColumn column = dt.Columns[columnName]; if (column == null) { column = new DataColumn(columnName, typeof(object)); dt.Columns.Add(column); } object rowValue = PrimitiveResolve.ReadObject(reader, handler); dr[columnName] = rowValue; if (reader.ReadBoolComma()) { move++; } } dr.EndEdit(); dt.Rows.Add(dr); reader.ReadObjRight(); if (reader.ReadBoolComma()) { moveNext++; } } reader.ReadArrayRight(); return(dt); }