internal static RowSchema ParseRowSchemaFromJson(string json) { JObject joType = JObject.Parse(json); string type = joType["type"].ToString(); List <ColumnSchema> columns = new List <ColumnSchema>(); List <JToken> jtFields = joType["fields"].Children().ToList(); foreach (JToken jtField in jtFields) { ColumnSchema col = ColumnSchema.ParseColumnSchemaFromJson(jtField.ToString()); columns.Add(col); } return(new RowSchema(type, columns)); }
internal static ColumnSchema ParseColumnSchemaFromJson(string json) { ColumnSchema col = new ColumnSchema(); JObject joField = JObject.Parse(json); col.name = joField["name"].ToString(); col.nullable = (bool)(joField["nullable"]); JToken jtType = joField["type"]; if (jtType.Type == JTokenType.String) { col.type = new RowSchema(joField["type"].ToString()); } else { col.type = RowSchema.ParseRowSchemaFromJson(joField["type"].ToString()); } return(col); }