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" ] }
  • 相关阅读:
    HDU 6071
    HDU 6073
    HDU 2124 Repair the Wall(贪心)
    HDU 2037 今年暑假不AC(贪心)
    HDU 1257 最少拦截系统(贪心)
    HDU 1789 Doing Homework again(贪心)
    HDU 1009 FatMouse' Trade(贪心)
    HDU 2216 Game III(BFS)
    HDU 1509 Windows Message Queue(队列)
    HDU 1081 To The Max(动态规划)
  • 原文地址:https://www.cnblogs.com/mr-yoatl/p/14721053.html
Copyright © 2011-2022 走看看