コード例 #1
0
        public void ParseFromJson(string json)
        {
            try
            {
                JsonNode root    = JsonNode.FromJson(json);
                JsonNode urlNode = root["url"];
                if (urlNode != null)
                {
                    Url = urlNode;
                }
                JsonNode statusCodeNode = root["statusCode"];
                if (statusCodeNode != null)
                {
                    StatusCode = statusCodeNode;
                }

                JsonNode contentNode = root["content"];
                if (contentNode != null)
                {
                    Content = contentNode;
                }

                JsonNode pathNode = root["path"];
                if (pathNode != null)
                {
                    Path = pathNode;
                }
            }
            catch (Exception exception)
            {
                XLog.LogError(TAG, exception.Message);
            }
        }
コード例 #2
0
    /// <summary>
    /// json:
    /// {"appId":"userId","":"channelId","":""}
    /// </summary>
    /// <param name="json"></param>
    public void PushInfoResult(string json)
    {
        Debug.Log("PushInfoResult:" + json);

        try
        {
            JsonNode root            = JsonNode.FromJson(json);
            var      appIdNode       = root["appId"];
            var      deviceTokenNode = root["deviceToken"];

            if (appIdNode != null)
            {
                string appId     = root["appId"];
                string userId    = root["userId"];
                string channelId = root["channelId"];
                foreach (PushInfoListener listener in Listeners)
                {
                    listener.OnBaiduPushInfo(appId, userId, channelId);
                }
            }

            if (deviceTokenNode != null)
            {
                string deviceToken = root["deviceToken"];
                foreach (PushInfoListener listener in Listeners)
                {
                    listener.OnIOSPushInfo(deviceToken);
                }
            }
        }
        catch (SimpleJson.SimpleJsonException e)
        {
            Debug.Log(e.Message);
        }
    }
コード例 #3
0
    IEnumerator Fetch()
    {
        //var www = new WWW(UrlPrefix + "fetch?device_id=" + Setting.DeviceUID);//TODO:恢复
        var www = new WWW(UrlPrefix + "fetch00.txt");

        yield return(www);

        if (www.error != null)
        {
            Debug.LogError("获取排行榜WWWW失败Error:" + www.error);
            yield break;
        }
        var text = www.text;

        try
        {
            var list         = new List <LeaderboardItem>();
            var json         = JsonNode.FromJson(text);
            var subNodeNames = json.SubNodeNames;
            if (subNodeNames.Contains("leaderboard_list"))
            {
                var jsonlist = json["leaderboard_list"];
                var count    = jsonlist.ElementNodeCount;
                for (var i = 0; i < count; i++)
                {
                    var item = jsonlist[i];
                    list.Add(new LeaderboardItem(item));
                }
            }
            else
            {
                Debug.LogError("json里没有leaderboard_list");
            }
            LeaderboardItem myItem = null;
            if (subNodeNames.Contains("player"))
            {
                var item = json["player"];
                myItem = new LeaderboardItem(item);
            }
            else
            {
                Debug.LogError("json里没有leaderboard_list");
            }
            Refresh(list, myItem);
        }
        catch (Exception)
        {
            throw;
        }
    }
コード例 #4
0
    /// <summary>
    /// json:{"uid":"1858307962","expires_in":"7751971","authType":1,"remind_in":"7751971","access_token":"2.00EnQlBCgTJYRD22eb73a2f6RG7bQC"}
    /// or
    /// json:{"authType":1,"code":"xxxxxxx"}
    /// </summary>
    /// <param name="result"></param>
    public void WeiboAuthResult(string result)
    {
        Debug.Log("WeiboAuthResult:   " + result);
        try
        {
            JsonNode root = JsonNode.FromJson(result);

            AuthType authType = (AuthType)(int)root["authType"].Value;


            ;



            var codeNode = root["code"];

            if (codeNode != null)
            {
                string code = (string)codeNode.Value;
                foreach (WeiboAuthListener listener in Listeners)
                {
                    listener.OnResult(authType, code);
                }
            }

            var tokenNode = root["access_token"];

            if (tokenNode != null)
            {
                string token    = root["access_token"];
                long   expireIn = root["expires_in"];
                long   uid      = root["uid"];
                foreach (WeiboAuthListener listener in Listeners)
                {
                    listener.OnResult(authType, uid, expireIn, token);
                }
            }
        }
        catch (SimpleJson.SimpleJsonException e)
        {
            Debug.Log(e.Message);
        }
    }
コード例 #5
0
    public void WxShareResult(string json)
    {
        XLog.Log(TAG, "share result : " + json + ",last share:" + (LastShareInfo == null?"":LastShareInfo.ToString()));

        try
        {
            JsonNode    node          = JsonNode.FromJson(json);
            JsonNode    errorCodeNode = node["errorCode"];
            int         code          = errorCodeNode;
            WxErrorCode errorCode     = (WxErrorCode)code;
            foreach (ShareResultListener listener in Listeners)
            {
                listener.Result(errorCode, LastShareInfo);
            }
        }
        catch (Exception exception)
        {
            XLog.LogError(TAG, exception.Message);
        }
    }
コード例 #6
0
        public void FromJson(string json)
        {
            try
            {
                JsonNode root = JsonNode.FromJson(json);

                JsonNode subjectNode = root["subject"];
                if (subjectNode != null)
                {
                    Subject = subjectNode;
                }

                JsonNode bodyNode = root["body"];
                if (bodyNode != null)
                {
                    Body = bodyNode;
                }

                JsonNode totalFeeNode = root["totalFee"];
                if (totalFeeNode != null)
                {
                    TotalFee = totalFeeNode;
                }

                JsonNode outTradeNoNode = root["outTradeNo"];
                if (outTradeNoNode != null)
                {
                    OutTradeNo = outTradeNoNode;
                }

                JsonNode notifyUrlNode = root["notifyUrl"];
                if (notifyUrlNode != null)
                {
                    NotifyUrl = notifyUrlNode;
                }
            }
            catch (Exception exception)
            {
                Debug.LogError(exception.Message);
            }
        }