private static RecordData CreateRecord(string json) { if (json.Length <= 0) { return(null); } json = json.Remove(0, 1); json = json.Remove(json.Length - 1, 1); bool stringData = false; int lastSplitter = 0; List <string> values = new List <string>(); for (int i = 0; i < json.Length; i++) { char c = json[i]; if (c == '"' && (i == 0 || json[i - 1] == ',')) { stringData = true; } if (c == '"' && (i == json.Length - 1 || json[i + 1] == ',')) { stringData = false; } if (c == ',' && !stringData) { values.Add(json.Substring(lastSplitter, i - lastSplitter)); lastSplitter = i + 1; } if (i == json.Length - 1) { values.Add(json.Substring(lastSplitter, json.Length - lastSplitter)); } } for (int i = 0; i < values.Count; i++) { values[i] = values[i].Replace(",", "").Replace("\"", "").Replace("\\", ""); } RecordData rec = new RecordData() { DataList = values.ToList() }; return(rec); }
private static TableRecordsClass GetFields(TableDataClass data) { var innerDataList = ParseDataScheme.ParseScheme(data.ClassData).ToList(); List <RecordData> records = new List <RecordData>(); for (int i = 0; i < innerDataList.Count; i++) { string str = innerDataList[i]; RecordData record = CreateRecord(str); if (record != null) { records.Add(record); } } var tableRecordsClass = new TableRecordsClass { ClassName = data.ClassName, ClassData = records }; return(tableRecordsClass); }