Ejemplo n.º 1
0
    static public List <string> LoadJson(string path)
    {
        Debug.Log(Directory.Exists(path).ToString());
        string[]      JsonsPath = Directory.GetFiles(path, "*");
        string        json;
        List <string> datas = new List <string>();

        foreach (string JsonPath in JsonsPath)
        {
            if (JsonPath.Contains(@".json"))
            {
                StreamReader sr = File.OpenText(JsonPath);
                json = sr.ReadLine();
                //datas.Add(JsonUtility.FromJson<_Data>(json));
                datas.Add(json);
                Debug.Log("Add data List");
            }
        }
        return(datas);
    }
Ejemplo n.º 2
0
        /// <summary>
        /// load Json内容
        /// </summary>
        public async void OnLoadContentClickAsync()
        {
            var content = "";

            if (JsonPath == null)
            {
                dialog.Content = "请先选择文件或输入url";
                dialog.ShowAsync();
                return;
            }
            // 判断地址类型
            if (JsonPath.Contains("http://") || JsonPath.Contains("https://"))
            {
                using (var hc = new HttpClient())
                {
                    content = await hc.GetStringAsync(new Uri(JsonPath));
                }
            }
            else
            {
                content = await FileIO.ReadTextAsync(JsonFile);
            }
            JsonContent = content.Replace("\t", "  ");
        }