zoukankan      html  css  js  c++  java
  • Litjson 解析接口数据出现: JsonException: Invalid character '' in input string

        /// <summary>
        /// 5.3.6f1 加载数据
        /// </summary>
        /// <returns></returns>
        IEnumerator ReadData()
        {
            WWW www = new WWW("http://127.0.0.1:12307/broadcast?type=refreshFileList");
            yield return www;
            Debug.Log(www.text);
            LitJson.JsonData data = LitJson.JsonMapper.ToObject(System.Text.Encoding.UTF8.GetString(www.bytes, 3, www.bytes.Length - 3));
            Debug.Log(data["state"]);
            for (var i = 0; i < data["data"].Count; i++)
            {
                Debug.Log(data["data"][i].ToString());
            }
        }
        /// <summary>
        /// 2019.4.0f1 加载数据
        /// </summary>
        /// <returns></returns>
        IEnumerator ReadData()
        {
            string url = "http://127.0.0.1:12307/broadcast?type=refreshFileList";
            var req = UnityWebRequest.Get(url);
            yield return req.SendWebRequest();
            var text = req.downloadHandler.text;
            Debug.Log(text);
            LitJson.JsonData data = LitJson.JsonMapper.ToObject(System.Text.Encoding.UTF8.GetString(req.downloadHandler.data, 3, req.downloadHandler.data.Length - 3));
            Debug.Log(data["state"]);
    
        }
    接口中返回的JSON数据:
    {
    "state":"200", "data":[ "D:\广播音频\Stream(2, 44.1k).wav", "D:\广播音频\Test1.wav", "D:\广播音频\播放.mp3" ] }
  • 相关阅读:
    luogu2394 yyy loves Chemistry I
    luogu2393 yyy loves Maths II
    2018年01月刷题学习日记
    luogu2590 [ZJOI2008]树的统计
    HDU 2087 剪花布条
    HDU 1686 Oulippo
    HDU 1711 Number Sequence(KMP模板)
    HDU 3336 Count the String(KMP+DP)
    UVa 1614 奇怪的股市
    UVa 12174 Shuffle(滑动窗口)
  • 原文地址:https://www.cnblogs.com/mr-yoatl/p/14721053.html
Copyright © 2011-2022 走看看