jsonDecode() public static method

Parses the string json into a value
public static jsonDecode ( string json ) : object
json string A JSON string.
return object
Example #1
0
        private void _RestoreCallBack(string data)
        {
            Hashtable res = (Hashtable)MiniJSON.jsonDecode(data);

            if (res == null || res.Count <= 0)
            {
                return;
            }

            string path = string.Empty;
            var    p    = res["path"];

            if (p != null)
            {
                path = p.ToString();
            }
            string source = string.Empty;
            var    s      = res["source"];

            if (s != null)
            {
                source = s.ToString();
            }
            Hashtable customParams = null;
            var       c_p          = res["params"];

            if (c_p != null)
            {
                customParams = (Hashtable)c_p;
            }
            MobLinkScene scene = new MobLinkScene(path, source, customParams);

            onRestoreScene(scene);
        }
Example #2
0
 private void Prepare()
 {
     try
     {
         var      files           = System.IO.Directory.GetFiles(Application.dataPath, "MOB.keypds", System.IO.SearchOption.AllDirectories);
         string   filePath        = files [0];
         FileInfo projectFileInfo = new FileInfo(filePath);
         if (projectFileInfo.Exists)
         {
             StreamReader sReader  = projectFileInfo.OpenText();
             string       contents = sReader.ReadToEnd();
             sReader.Close();
             sReader.Dispose();
             Hashtable datastore = (Hashtable)MiniJSON.jsonDecode(contents);
             appKey    = (string)datastore["MobAppKey"];
             appSecret = (string)datastore["MobAppSecret"];
         }
         else
         {
             Debug.LogWarning("MOB.keypds no find");
         }
     }
     catch (Exception e)
     {
         if (appKey.Length == 0)
         {
             appKey    = "moba6b6c6d6";
             appSecret = "b89d2427a3bc7ad1aea1e1e8c1d36bf3";
         }
         Debug.LogException(e);
     }
 }
Example #3
0
    public void SetChanged(string _json)
    {
        Hashtable jd  = MiniJSON.jsonDecode(_json) as Hashtable;
        Direction dir = (Direction)int.Parse(jd ["dir"].ToString());
        float     val = float.Parse(jd ["val"].ToString());

        changeDirection(dir);
        switch (dir)
        {
        case Direction.Left:
            LeftTwist(val);
            break;

        case Direction.Right:
            RightTwist(val);
            break;

        case Direction.Up:
            UpTwist(val);
            break;

        case Direction.Down:
            DownTwist(val);
            break;
        }
        if (val > 0.5f)
        {
            isshow = false;
            showpoker();
            return;
        }
    }
        // 加载本地配置数据
        public static void GetLocalData(string fileName, OnLoadCompletedDelegate callback)
        {
            string fileData = string.Empty;
            string fullPath = GetConfigFullPath(fileName);

            if (File.Exists(fullPath))
            {
                byte[] fileBytes = ReadFile(fullPath);
                fileData = System.Text.Encoding.UTF8.GetString(fileBytes);
                Debug.LogError(fileData);
            }
            else
            {
                Debug.LogError("no " + fullPath);
            }
            object jsonObj = MiniJSON.jsonDecode(fileData);

            if (jsonObj == null)
            {
                Debug.Log("Data conversion fails, Get the data address name:" + fileName);
            }
            if (null != jsonObj && (jsonObj is Hashtable) && null != callback)
            {
                Hashtable hashJson = jsonObj as Hashtable;
                int       result   = int.Parse(hashJson["return_code"].ToString());
                callback(hashJson["data_content"], result);
            }
            else
            {
                Debug.Log("decode json error filename:" + fileName);
                callback(null, 0);
            }
        }
Example #5
0
    /// StreamReader读取文件
    /// <param name="path"></param>
    /// <returns></returns>
    public static Hashtable GetJsonFileWithStream(string path)
    {
        FileStream file;

        try
        {
            if (File.Exists(path))
            {
                file = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
            }
            else
            {
                return(null);
            }
        }
        catch (FileLoadException ex)
        {
            Debug.Log("#Error : Open file which path of : " + path + " : " + ex.Message);
            return(null);
        }

        StreamReader streamReader = new StreamReader(file, System.Text.Encoding.UTF8);
        string       jsonData     = streamReader.ReadToEnd();

        streamReader.Close();
        file.Close();

        if (jsonData != null)
        {
            return(MiniJSON.jsonDecode(jsonData) as Hashtable);
        }
        return(null);
    }
Example #6
0
        private void _MobPushDemoCallback(string data)
        {
            if (data == null)
            {
                return;
            }
            Debug.Log("_MobPushDemoCallback:" + data);
            Hashtable res = (Hashtable)MiniJSON.jsonDecode(data);

            if (res == null || res.Count <= 0)
            {
                return;
            }
            int  action = Convert.ToInt32(res["action"]);
            bool isSuccess;

            if (action == 1)
            {
                isSuccess = true;
            }
            else
            {
                isSuccess = false;
            }
            if (onDemoReqCallback != null)
            {
                onDemoReqCallback(isSuccess);
            }
        }
Example #7
0
    void LoadData(string dataString)
    {
        //Debug.Log ("Load: " + dataString );

        //try {

        Hashtable data = (Hashtable)MiniJSON.jsonDecode(dataString);

        foreach (ISerializable serializable in serializables)
        {
            if (data != null && data.ContainsKey(serializable.ID))
            {
                serializable.Deserialize((Hashtable)data[serializable.ID]);
            }
            else
            {
                serializable.Deserialize(new Hashtable());
            }
        }

        loaded = true;

//		} catch( Exception e ) {
//			Debug.LogError( new Exception("Error loading from save data: " + e.ToString(), e ) );
//			Application.LoadLevel (0);
//		}
    }
    IEnumerator SendPostIos(string _url, WWWForm _wForm)
    {
        WWW postData = new WWW(_url, _wForm);

        yield return(postData);

        Hashtable d = (Hashtable)MiniJSON.jsonDecode(postData.text);

        if (postData.error != null || Convert.ToInt32(d["ResultCode"]) == 0)
        {
            Debug.Log("Unity 网络请求失败:" + postData.error);
            if (d["Data"] != null)
            {
                mfailure.Call(Convert.ToString(d["Data"]));
            }
            else
            {
                mfailure.Call("验证失败");
            }
        }
        else
        {
            mSuccess.Call("支付成功");
            deleteReceiptString();
            reconnectCount = 0;
        }
    }
Example #9
0
    private static void Initialize(string rawData)
    {
        Hashtable   hashtable  = MiniJSON.jsonDecode(rawData) as Hashtable;
        ArrayList   arrayList  = hashtable["data"] as ArrayList;
        int         num        = Enum.GetNames(typeof(LootCrateType)).Length - 1;
        IEnumerator enumerator = arrayList.GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                object    obj  = enumerator.Current;
                Hashtable data = (Hashtable)obj;
                Slot      slot = new Slot(data);
                for (int i = 0; i < num; i++)
                {
                    LootCrateType lootCrateType = (LootCrateType)i;
                    if (slot.ForLootCrate(lootCrateType))
                    {
                        LootCrateRewards.Slots[lootCrateType].Add(slot);
                    }
                }
            }
        }
        finally
        {
            IDisposable disposable;
            if ((disposable = (enumerator as IDisposable)) != null)
            {
                disposable.Dispose();
            }
        }
        LootCrateRewards.initialized = true;
    }
    private void OnDataLoaded(string rawData)
    {
        this.config = new Dictionary <string, ConfigData>();
        Hashtable             hashtable  = MiniJSON.jsonDecode(rawData) as Hashtable;
        IDictionaryEnumerator enumerator = hashtable.GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                object          obj             = enumerator.Current;
                DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
                try
                {
                    this.config.Add((string)dictionaryEntry.Key, new ConfigData((string)dictionaryEntry.Key, (Hashtable)dictionaryEntry.Value));
                }
                catch
                {
                }
            }
        }
        finally
        {
            IDisposable disposable = enumerator as IDisposable;
            if (disposable != null)
            {
                disposable.Dispose();
            }
        }
        this.hasData = true;
        if (this.OnHasData != null)
        {
            this.OnHasData();
        }
    }
Example #11
0
    IEnumerator HttpGetTestCoroutine()
    {
        // 2. 통신 url 작성
        string url = "http://127.0.0.1/get_sum.php";

        // 3. get 파라미터 설정
        string getParamUrl = url + "?val1 = 10 & val2 = 40";

        // 4. HTTP 통신객체 생성(www) 및 통신 요청
        WWW www = new WWW(getParamUrl);

        yield return(www); // 5. 통신 응답 대기

        // 6. 통신 에러 체크
        // 만약 통신 에러가 발생했다면 (error 객체가 null 이 아님)
        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.Log(www.error); //에러 메세지 출력
            yield break;
        }

        // 7. 응답 받은 데이타 출력
        Debug.Log(www.text);

        // JSON 문자열 -> C#의 딕셔너리(사전) 객체로 전환
        Dictionary <string, object> responseData =
            (Dictionary <string, object>)MiniJSON.jsonDecode(www.text.Trim());

        Debug.Log("val1 => " + responseData["val1"]);
        Debug.Log("val2 => " + responseData["val2"]);
        Debug.Log("data => " + responseData["data"]);
    }
Example #12
0
    private bool LoadData(string path, out Hashtable data)
    {
        if (!File.Exists(path))
        {
            data = null;
            return(false);
        }
        StreamReader streamReader = null;
        bool         result;

        try
        {
            streamReader = new StreamReader(path);
            string json = streamReader.ReadToEnd();
            data   = (MiniJSON.jsonDecode(json) as Hashtable);
            result = true;
        }
        catch
        {
            data   = null;
            result = false;
        }
        finally
        {
            if (streamReader != null)
            {
                streamReader.Dispose();
            }
        }
        return(result);
    }
Example #13
0
        public CancelDelegate ReadGame(ResultCallback cb)
        {
            WebClient client = new WebClient();

            client.DownloadStringCompleted += (object sender, DownloadStringCompletedEventArgs e) => {
                bool result = false;
                try {
                    if (e.Cancelled)
                    {
                        Logging.Log("ReadGame cancelled");
                    }
                    else if (e.Error != null)
                    {
                        Logging.LogException(e.Error);
                    }
                    else
                    {
                        string json = e.Result;
                        Logging.Log("ReadGame: " + json);
                        Hashtable ht = MiniJSON.jsonDecode(json) as Hashtable;
                        checkError(ht);
                        game   = new Game(ht);
                        result = true;
                    }
                } catch (Exception exc) {
                    /* Job failed, but we still have to exit job state */
                    Logging.LogException(exc);
                }
                cb.Invoke(result);
            };
            client.DownloadStringAsync(Page("/game", "name={0}", inGame));
            return(client.CancelAsync);
        }
Example #14
0
        /// <summary>
        /// Callback the specified data.
        /// </summary>
        /// <param name="data">Data.</param>
        public static void shareRECCallback(string data)
        {
            object dataObj = MiniJSON.jsonDecode(data);

            if (dataObj is Hashtable)
            {
                Hashtable dataTable = dataObj as Hashtable;
                if (dataTable != null && dataTable.ContainsKey("name"))
                {
                    string name = dataTable ["name"] as string;
                    switch (name)
                    {
                    case "StopRecordingFinished":
                    {
                        Exception ex = null;
                        if (dataTable.ContainsKey("error"))
                        {
                            string errorMessage = null;

                            Hashtable error = dataTable["error"] as Hashtable;
                            if (error.ContainsKey("message"))
                            {
                                errorMessage = error["message"] as string;
                            }

                            ex = new Exception(errorMessage);
                        }

                        //finished record
                        if (_finishedRecordHandler != null)
                        {
                            _finishedRecordHandler(ex);
                        }
                        break;
                    }

                    case "SocialClose":
                        if (_closeHandler != null)
                        {
                            _closeHandler();
                        }
                        break;

                    case "EditResult":
                        bool cancelled = false;
                        if (dataTable.ContainsKey("cancelled"))
                        {
                            cancelled = Convert.ToBoolean(dataTable["cancelled"]);
                        }

                        if (_editResultHandler != null)
                        {
                            _editResultHandler(cancelled);
                        }
                        break;
                    }
                }
            }
        }
Example #15
0
    private void SendToCreate()
    {
        string directory = GLexConfig.BasePathWithoutSceneName;
        string zip       = GLexConfig.BasePathWithoutSceneName + GLexSceneSettings.FileName + ".zip";

        Compress(directory, zip);

        EditorUtility.DisplayProgressBar("Preparing to upload", string.Empty, 0);
        WWWForm form = new WWWForm();

        form.AddBinaryData("zip", File.ReadAllBytes(zip));
        form.AddField("token", GLex.Instance.ImportToken);

        if (GLex.Instance.ProjectId.Length > 0)
        {
            form.AddField("project_id", GLex.Instance.ProjectId);
        }

        WWW www;

        if (createBaseURL.IndexOf("dev") != -1)
        {
            www = new WWW("http://*****:*****@create.dev.gooengine.com/api/import", form);
        }
        else
        {
            www = new WWW(createBaseURL + "api/import", form);
        }

        while (!www.isDone)
        {
            EditorUtility.DisplayProgressBar("Uploading to Goo Create", "Sending files", www.progress);
        }

        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.LogError("Error occured while trying to upload to goo create: " + www.error);
        }
        else
        {
            Hashtable response = MiniJSON.jsonDecode(www.text) as Hashtable;
            if (response != null)
            {
                string status = response.ContainsKey("status") ? Convert.ToString(response["status"]) : "";

                if (!status.Equals("200"))
                {
                    EditorUtility.DisplayDialog("Upload failed", response["message"].ToString(), "ok");
                    Debug.LogError("GooExporter.SendToCreate: " + response["message"]);
                }
            }
            else
            {
                EditorUtility.DisplayDialog("Upload failed", www.text, "ok");
                Debug.LogError("Error occured while trying to upload to goo create: " + www.text);
            }
        }
    }
Example #16
0
        private void _MobIdCallback(string data)
        {
            // 解析出mobId
            Hashtable json  = (Hashtable)MiniJSON.jsonDecode(data);
            string    modId = json["mobid"].ToString();

            onGetMobId(modId);
            onGetMobId = null;
        }
Example #17
0
    /// <summary>
    /// 获取配置文件
    /// </summary>
    /// <returns></returns>
    public static Hashtable GetJsonFile(string path, bool isUncompress = true)
    {
        byte[] buff = GetFileBytes(path, isUncompress);

        if (buff != null)
        {
            return(MiniJSON.jsonDecode(System.Text.UTF8Encoding.UTF8.GetString(buff)) as Hashtable);
        }
        return(null);
    }
Example #18
0
    public override void ProcessMsg(int msgType, byte[] msg)
    {
        string js = System.Text.Encoding.UTF8.GetString(msg);
        object jd = MiniJSON.jsonDecode(js);

        if (mapFuncs.ContainsKey(msgType))
        {
            mapFuncs[msgType](jd);
        }
    }
Example #19
0
        void Awake()
        {
            TextAsset text = Resources.Load <TextAsset>("Text/StaticInfo");

            dictStaticInfo = MiniJSON.jsonDecode(text.text) as Hashtable;

            text           = Resources.Load <TextAsset>("Text/StaticText");
            dictStaticText = MiniJSON.jsonDecode(text.text) as Hashtable;

            SetRect();
        }
        //读取配置debug.logdebug.log
        private void ReadMobpds(string filePath, string appkey, string savefilePath, Hashtable deviceInfo)
        {
            FileInfo fileInfo = new FileInfo(filePath);

            if (fileInfo.Exists)
            {
                StreamReader sReader  = fileInfo.OpenText();
                string       contents = sReader.ReadToEnd();
                sReader.Close();
                sReader.Dispose();
                Hashtable datastore = (Hashtable)MiniJSON.jsonDecode(contents);
                //savefilePath


                int index = filePath.LastIndexOf("\\");
                if (index == -1)
                {
                    index = filePath.LastIndexOf("/");
                }
                if (savefilePath == null)
                {
                    savefilePath = filePath;
                    savefilePath = savefilePath.Substring(0, index);
                }


                //permissionsreplaceAppKeydebug.logdebug.log
                AddPrmissions(datastore);
                //LSApplicationQueriesSchemes
                AddLSApplicationQueriesSchemes(datastore, appkey, deviceInfo);
                //folders
                AddFolders(datastore, savefilePath);
                //buildSettings
                AddBuildSettings(datastore);
                //系统库添加
                AddSysFrameworks(datastore);
                //添加非系统 Framework 配置需要设置指定参数
                AddFrameworks(datastore, savefilePath);
                //添加 URLSchemes
                AddURLSchemes(datastore, appkey, deviceInfo);
                //添加 InfoPlistSet
                AddInfoPlistSet(datastore, appkey, deviceInfo);
                //子平台
                AddPlatformConf(datastore, savefilePath);
                //添加 fileFlags 一些需要特殊设置编译标签的文件 如ARC下MRC
                AddFileFlags(datastore);

                //添加场景还原
                AddRestoreScene(datastore, savefilePath);

                //添加associatedDomains
                AddAssociatedDomains(datastore, savefilePath);
            }
        }
Example #21
0
    public void onDispatch(ProtocolTypes type, byte[] json)
    {
        string    jsonStr = Encoding.UTF8.GetString(json);
        Hashtable res     = (Hashtable)MiniJSON.jsonDecode(jsonStr);

        if (res == null || res.Count <= 0)
        {
            return;
        }
        onRecv.Invoke(type, res);
    }
Example #22
0
    public List <Hashtable> ParserJson(string content)
    {
        List <Hashtable> htLists = new List <Hashtable>();

        // use MiniJson to let Json to string
        Hashtable data = MiniJSON.jsonDecode(content) as Hashtable;

        Debug.Log("status    =" + data["status"]);
        Debug.Log("contend   =" + data["content"]);
        Debug.Log("pagecount =" + data["pagecount"]);
        Debug.Log("page      =" + data["page"]);
        Debug.Log("list      =" + data["list"]);

        ArrayList dataList = data["list"] as ArrayList;

        List <int>    idList     = new List <int>();
        List <string> titileList = new List <string>();
        List <string> picList    = new List <string>();
        List <string> urlList    = new List <string>();

        foreach (Hashtable item in dataList)
        {
            // Debug.Log("id = " + item["id"]);
            idList.Add(Convert.ToInt32(item["id"]));

            // Debug.Log("title = " + item["title"]);
            titileList.Add(Convert.ToString(item["title"]));

            // Debug.Log("picture =" + item["pic"]);
            picList.Add(Convert.ToString(item["pic"]));

            urlList.Add(Convert.ToString(item["playurl"]));
        }


        //List<object> datas = MiniJSON.jsonDecode(content) as List<object>;

        ArrayList list = new ArrayList();// data as ArrayList;

        if (list != null)
        {
            for (int i = 0; i < list.Count; i++)
            {
                Hashtable ht = list[i] as Hashtable;
                htLists.Add(ht);
            }
        }
        else
        {
            Debug.Log("MiniJson parse failure");
        }
        return(htLists);
    }
Example #23
0
 public void ExecuteCallBack(string str)
 {
     if (MiniJSON.jsonDecode(str) is Hashtable table)
     {
         var cbName  = table["Method"] as string;
         var content = table["Content"] as string;
         if (_sdkCallbackDict.ContainsKey(cbName))
         {
             _sdkCallbackDict[cbName]?.Invoke(content);
         }
     }
 }
Example #24
0
    IEnumerator LoadRankCoroutine()
    {
        string url = "http://127.0.0.1/clickergame/selectorderby.php";

        WWW www = new WWW(url);

        yield return(www);

        if (string.IsNullOrEmpty(www.error))
        {
            Dictionary <string, object> rankData = MiniJSON.jsonDecode(www.text) as Dictionary <string, object>;

            string result = rankData["RESULT"].ToString();

            // 순위 조회 데이타 성공했다면
            if (result.Equals("ORDERBY_SUCCESS"))
            {
                // 순위 리스트를 참조함
                List <object> rankList = rankData["DATA_LIST"] as List <object>;

                float posY = 0; //행 생성 위치 y

                //리스트
                for (int i = 0; i < rankList.Count; i++)
                {
                    Dictionary <string, object> rankRowData = rankList[i] as Dictionary <string, object>;

                    Debug.Log((i + 1).ToString() + "등 유저 아이디 : " + rankRowData["nick_name"].ToString());

                    //랭크 정보를 표시할 행 오브젝트 생성
                    GameObject row = Instantiate(_rankInfoPenelPrefab, Vector2.zero, Quaternion.identity, _contentViewTr);

                    row.GetComponent <RectTransform>().anchoredPosition = new Vector2(0f, posY);

                    //랭크 정보를 행패널에 설정함
                    CRankInfoPanel rankInfo = row.GetComponent <CRankInfoPanel>();
                    rankInfo.SetRankInfo(rankRowData["nick_name"].ToString(), rankRowData["best_click_count"].ToString());

                    posY -= 100f;
                }

                // Content 뷰의 크기를 행 갯수에 맞게 키워줌

                RectTransform rt = _contentViewTr.GetComponent <RectTransform>();
                rt.sizeDelta = new Vector2(rt.sizeDelta.x, Mathf.Abs(posY));
            }

            else
            {
                Debug.Log("통신오류 발생");
            }
        }
    }
Example #25
0
    public IEnumerator ParseCoroutine()
    {
        string url = "https://91igu4dgel.execute-api.ap-northeast-2.amazonaws.com/prod/tracks/suggestions?mood=" + mood + "&weather=" + weather + "&count=20";

        Debug.Log(url);

        WWWForm form = new WWWForm();
        WWW     www  = new WWW(url);

        yield return(www);

        if (www.error == null)
        {
            int nMax   = 0;
            int nIndex = 0;

            List <object> listArray = MiniJSON.jsonDecode(www.text) as List <object>;
            // Dictionary<string, object> dictData = listArray["track"] as Dictionary<string, object>;

            // List<object> trackData = dictData["track"] as List<object>;
            // Debug.Log(listArray.Count);

            for (int i = 0; i < listArray.Count; i++)
            {
                Dictionary <string, object> dicData = listArray[i] as Dictionary <string, object>;
                //  Debug.Log(dicData.Count);

                // for (int j = 0; j < dicData.Count; j++) {
                //  Dictionary<string, object> dictData = dicData["track"] as Dictionary<string, object>;
                //  Debug.Log(dicData.Values);
                // }

                // int nDownloadCount = int.Parse(dicData["playback_count"]+"");
                // if ( nDownloadCount >= nMax ) {
                //  nMax = nDownloadCount;
                //  nIndex = i;
                // }
            }

            // Dictionary<string, object> data = trackData[nIndex] as Dictionary<string, object>;

            // Debug.Log( "최고점수 : " + nMax );
            // Debug.Log( "노래제목 : " + data["title"] );
            // Debug.Log( "노래제목 : " + data["download_url"] );

            // StartCoroutine("downloadMusic", data["download_url"]);
        }
        else
        {
            Debug.Log(www.error);
        }
    }
Example #26
0
    public static Hashtable GetJsonFile(byte[] buff, bool isUncompress = true)
    {
        if (isUncompress && buff != null)
        {
            buff = ZipLibUtils.Uncompress(buff);
        }

        if (buff != null)
        {
            return(MiniJSON.jsonDecode(System.Text.UTF8Encoding.UTF8.GetString(buff)) as Hashtable);
        }
        return(null);
    }
Example #27
0
        public ArrayList GetObjects()
        {
            string filename = "../../../../resources/field_mapping.json";

            try {
                System.IO.StreamReader file = new System.IO.StreamReader(filename);
                object data = MiniJSON.jsonDecode(file.ReadToEnd());
                return((ArrayList)data);
            } catch (InvalidCastException ex) {
                Console.WriteLine("Could not parse " + filename + ", encountered error " + ex);
                return(new ArrayList());
            }
        }
Example #28
0
    // 가입 및 로그인 처리하는 코루틴
    private IEnumerator JoinOrLoginNetCoroutine(string _userId)
    {
        // 가입 및 로그인 url 작성
        string _url = CSocialNetworkManager.baseUrl + "/user_account.php";

        // 유저 아이디값을 POST 파라미터로 설정해 줌
        WWWForm _form = new WWWForm();

        _form.AddField("device", _userId);

        // 가입 및 로그인 요청을 수행함
        WWW _www = new WWW(_url, _form);

        // 통신을 지연을 대기함
        yield return(_www);

        if (_www.error == null)
        {
            Debug.Log("data -> " + _www.text);

            // 응답 받은 json 문자열을 Dictionary 객체로 변환함
            Dictionary <string, object> _responseData
                = MiniJSON.jsonDecode(_www.text) as Dictionary <string, object>;

            string _result_code = _responseData["result_code"].ToString().Trim();

            if (_result_code.Equals("LOGIN_SUCCESS"))
            {
                // 유저 정보를 셋팅함
                userInfo.SetUserInfo(_responseData);

                // 닉네임을 아직 안 정했으면
                if (userInfo.nickName.Equals("0"))
                {
                    changeIdPanel.SetActive(true);
                }
                else
                {
                    _pressAnyObj.SetActive(true);
                }
            }
            else
            {
                Debug.Log("게임 서버 로그인에 실패함");
            }
        }
        else
        {
            Debug.Log("error -> " + _www.error);
        }
    }
Example #29
0
    // 서버의 별점을 갱신을 요청함
    IEnumerator UpdateStarCountNetCoroutine(int bestStarCount,
                                            int totalStarCount, GameObject callback)
    {
        // 별점 정보 갱신 URL 설정
        string url = CSocialNetworkManager.baseUrl + "/user_starcount_update.php";

        // 별점 정보 갱신용 POST 파라미터 설정
        WWWForm wwwForm = new WWWForm();

        wwwForm.AddField("user_id", _userId.Trim());
        wwwForm.AddField("best_star_count", bestStarCount);
        wwwForm.AddField("total_star_count", totalStarCount);

        // 별점 정보 갱신을 요청함
        WWW www = new WWW(url, wwwForm);

        yield return(www);

        if (www.error == null)
        {
            Dictionary <string, object> responseData = MiniJSON.jsonDecode(www.text)
                                                       as Dictionary <string, object>;

            string result = responseData["result_code"].ToString().Trim();
            //string result = "STARCOUNT_UPDATE_SUCCESS";

            Debug.Log("www.text => " + www.text);
            Debug.Log("Update Star Count Result => " + result);

            // 별점 정보 갱신을 성공함
            if (result == "STARCOUNT_UPDATE_SUCCESS")
            {
                // 서버 업데이트가 성공했다면 게임 데이타를 갱신함
                _bestStarCount  = bestStarCount;
                _totalStarCount = totalStarCount;
                Debug.Log("Update Star Count Success");

                callback.SendMessage("GameEndComplte", "점수 갱신 완료");
            }
            else
            {
                callback.SendMessage("GameEndComplte", "점수 갱신 실패");

                Debug.Log("Update Star Count Fail");
            }
        }
        else
        {
            Debug.Log(www.error);
        }
    }
Example #30
0
    IEnumerator Post_Enumerator(string url, WWWForm form, Action <Hashtable> Post_CB)
    {
        using (var request = UnityWebRequest.Post(url, form))
        {
            yield return(request.SendWebRequest());

            if (!request.isNetworkError && !request.isHttpError)
            {
                var str  = request.downloadHandler.text;
                var hash = MiniJSON.jsonDecode(str) as Hashtable;
                Post_CB?.Invoke(hash);
            }
        }
    }