public static void JsonToCSV(string path) { try { using (StreamReader sr = new StreamReader(path)) { List <string> contents = ParseJsonToCSV.ConvertJsonToCSV(sr); if (contents != null && contents.Count > 0) { StreamWriter sw = File.CreateText(path.Replace("bytes", "csv")); foreach (string item in contents) { sw.WriteLine(GB2312UnicodeConverter.ToGB2312(item)); } sw.Close(); } else { UnityEngine.Debug.LogError("JsonToCSV null"); } } } catch (Exception e) { UnityEngine.Debug.Log("The process failed: " + e.ToString()); } }
public static List <string> ConvertJsonToCSV(StreamReader sr) { if (instance != null) { instance.ClearData(); instance = null; } instance = new ParseJsonToCSV(); if (instance != null) { instance.mSR = sr; instance.ClearData(); return(instance.Convert()); } return(null); }