标签:info debug byte _id ati json turn art object
Unity3d使用json能够借助LitJson
下载LitJson,复制到Unity3d工作文件夹下
于是能够在代码中实现了
以下发送请求到server并解析
System.Collections.Hashtable headers = new System.Collections.Hashtable (); headers.Add ("Content-Type","application/x-www-form-urlencoded"); string data = "token="+User.token; byte[] bs = System.Text.UTF8Encoding.UTF8.GetBytes (data); WWW www = new WWW ("http://127.0.0.1:8080/userver/st",bs,headers); yield return www; if(www.error!=null){ m_info=www.error; yield return null; } JsonData listJson = JsonMapper.ToObject (www.text); //server返回map数组 Debug.Log (listJson[0][0]); //json对象的值能够通过下标或者key获取 Debug.Log (listJson[0]["r"]);
</pre><pre code_snippet_id="503706" snippet_file_name="blog_20141031_3_1427346" name="code" class="csharp">以下是server数据
</pre><pre code_snippet_id="503706" snippet_file_name="blog_20141031_5_2276003" name="code" class="java"> Map<String,Object> map=new HashMap<String,Object>(); map.put("r","1212121212d12"); map.put("e","1212121212a12"); map.put("a","1212121212d12"); map.put("f","1212121212c12"); map.put("d","12121212121g2"); map.put("s","sdfdsfds");
标签:info debug byte _id ati json turn art object
原文地址:http://www.cnblogs.com/cxchanpin/p/7309034.html