找回密码
 立即注册
楼主: ruizi

[脚本] Unity3D Json LitJson Data解析服务端代码

[复制链接]
发表于 2013-3-5 13:57 | 显示全部楼层 |阅读模式
如果接收这样的字符串:{"Data":{"UserID":"26","NickName":"werw@163.com","AssociationID":"0","VipHeader":"0","VipLevel":"0","Level":"0","Exp2Level":"0","Exp":"0","ExpRate":"0.00","Money":"0","MoneyRate":"0.00","Gold":"0","MaxPower":"0","CurPower":"0","TaskSec":"0","FinshGuideTask":"0","Vigour":{"VigourValueMax":"200","VigourRecoverTime":0,"VigourRecoverRate":"0.20","VigourRecoverTMaxSec":21600},"Strength":{"StrengthValueMax":"5","StrengthRecoverTime":0,"StrengthRecoverRate":"0.20","StrengthRecoverTMaxSec":21600}},"Verify":"7581f48a093bc40c54c28615e1d7ddab"}

Plugins\LitJson dll此目录
http://lbv.github.io/litjson/
最新litjson包

jsonmapper已支持IOS
首先下载一个LitJson 放在 asset 文件夹plugins中

然后写一个脚本

using UnityEngine;
using System.Collections.Generic;
using System.Collections;
using LitJson;

public class Script : MonoBehaviour {
        
        public string strURL="http://u3dchina.com/?CH=Users&Opt=View&UserID=26";
        // Use this for initialization
        void Start () {
                StartCoroutine(GetMethod());
        }
        IEnumerator GetMethod()
        {
                WWW getwww=new WWW(strURL);
                yield return getwww;
                print (getwww.data);
                JsonData jd=JsonMapper.ToObject(getwww.data);
                print (jd["Data"]["UserID"]);
                print (jd["Data"]["Vigour"]["VigourValueMax"]);
                print (jd["Verify"]);
       }
}

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

评分

参与人数 4鲜花 +2 +2 收起 理由
Neilyo + 1 赞一个!
aa1287537617 + 1
graywolfx21 + 1 赞一个!
yugo215 + 1 赞一个!

查看全部评分

发表于 2013-3-15 10:02 | 显示全部楼层
这个ios上面是不可以用的,jsonmapper无法使用
 楼主| 发表于 2013-3-19 11:25 | 显示全部楼层
江南 发表于 2013-3-15 10:02
这个ios上面是不可以用的,jsonmapper无法使用

怎么测试的呢 jsonfx可以吗
发表于 2013-6-3 22:54 | 显示全部楼层

感谢楼主的无私分享!{:soso__11402694654016840197_7:}
发表于 2013-12-28 15:03 | 显示全部楼层
js编程用litJSON在IOS下时不时会出错
发表于 2014-6-30 14:10 | 显示全部楼层
jsonmapper无法使用...
发表于 2017-3-23 08:49 | 显示全部楼层
很不错
发表于 2017-3-23 08:51 | 显示全部楼层
真心顶
发表于 2017-3-23 09:05 | 显示全部楼层
难得一见的好帖
发表于 2017-3-23 09:31 | 显示全部楼层
说的非常好
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-3 19:43 , Processed in 0.576241 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表