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");

Unity3d使用json与javaserver通信的更多相关文章

  1. Unity3d之json解析研究

    Unity3d之json解析研究     json是好东西啊!JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式      JSON简单易用,我要好好研究一下 ...

  2. Unity3D游戏,TCP,WEBCOSKT,HTTP通信架构 weaving-socket

    weaving-socket 详细介绍 项目简介 2017-8-8:新发布功能 增加U3D游戏客户的通讯项目支持,并提供示例内容. 2017-5-5: 新发布 weaving-socket 架构的.n ...

  3. [PHP 作为iOS后台Json格式HTTP通信及文件上传的实现]

    1.数据库连接 configmysql.php <?php $q = mysql_connect("localhost:8889","root",&quo ...

  4. Unity3D 通过JSON查询天气

    一.天气查询API 获取天气信息,首先要找到提供天气数据的接口,我使用的是高德地图免费为我们提供的,网址为 https://lbs.amap.com/api/webservice/guide/api/ ...

  5. json方式封装接口通信

    编写response类: <?php class response{ /** * 按json方式输出通信数据 * @param integer $code 状态码 * @param string ...

  6. 04 json,xml混合封装通信

    <?php class Response_json_xml{ public static function show($code,$message="",$data=arra ...

  7. NetworkComms V3 使用Json序列化器进行网络通信

    刚才在网上闲逛,偶然看到一篇文章 C#(服务器)与Java(客户端)通过Socket传递对象 网址是:http://www.cnblogs.com/iyangyuan/archive/2012/12/ ...

  8. php和js如何通过json互相传递数据

    当我们在结合php和javascript实现某些功能时,经常会用到json.json是js的一种数据格式,可以直接被js解析.而php无法直接读取json数据,但是php提供了json_decode函 ...

  9. php生成json或者xml数据

    , ,'数据返回成功',$arr);echo $xml;?>

随机推荐

  1. Entity Framework(实体框架 EF)

    什么是Entity Framework呢(下面简称EF)? EF(实体框架)是ADO.NET中的一组支持开发面向数据的软件应用程序的技术,是微软的一个ORM框架.ORM(对象关系映射框架):指的是面向 ...

  2. Test20171009 考试总结 NOIP模拟赛

    题目难度合适,区分度适中,但是本人水平不佳,没有拿到满意的分数. T1(matrix) 一种比较容易想到的想法是枚举起点求出最长全1串做预处理,这是O(n^2)的. 接着枚举列起点,列终点,通过后缀和 ...

  3. Codeforces Round #302 (Div. 2) C. Writing Code 简单dp

    C. Writing Code Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/544/prob ...

  4. unix/linux中如何在vi编辑器中方便的跳转到首行和末行?

    1.跳转到首行,:0/:1 2.跳转到末行,shift +g/G/:$

  5. C# 7.0中可能出现的语法

    今天在MSDN上看到的微软关于微软关于C# 7.0特性的Work List,主要特性如下: Tuple增强 Tuple的可读性一直不是很好, 很多时候宁愿新写一个类也不使用Item1, Item2这种 ...

  6. ADC for programmable logic uses one capacitor

    Many electronic devices require user input for setting the application properties. Typical input dev ...

  7. gdb逆向调试

    http://blog.csdn.net/yiling2012/article/details/35988361

  8. (转)h264中avc和flv数据的解析

    计算 AVCDecoderConfigurationRecord  得到 CodecPrivateData 数据(只有第一帧需要): 计算 NALUs 得到帧数据. 计算 AVCDecoderConf ...

  9. 【spring】在spring cloud项目中使用@ControllerAdvice做自定义异常拦截,无效 解决原因

    之前在spring boot服务中使用@ControllerAdvice做自定义异常拦截,完全没有问题!!! GitHub源码地址: 但是现在在spring cloud中使用@ControllerAd ...

  10. KVM-Introduce

    相信非常多的人对虚拟机并不陌生,眼下也有非常多优秀的虚拟机软件,比如:VMware, VirtualBox, Xen, KVM等.而本文的主要内容是介绍KVM. KVM: Kernel Based V ...