示例#1
0
        /*****************************    读取Json数据             *************************/
        private bool readJson(String arrayData)
        {
            try
            {
                dictData.Clear();

                protocolNumber = (int)TCPPROTOCOL.INVALID;

                JSONObject jsonObject = new JSONObject(arrayData);

                JSONObject jsonData = jsonObject.GetJSONObject("data");

                foreach (String key in jsonData.GetKeys())
                {
                    dictData[key] = jsonData.GetString(key);
                }

                protocolNumber = Convert.ToInt32(dictData["protocol"]);

                dictData.Remove("protocol");

                return(true);
            }
            catch (JSONException e)
            {
                return(false);
            }
        }
示例#2
0
    private void LoadDictionary(string dictFileName, Dictionary <string, string> outputDict)
    {
        TextAsset  ta      = Resources.Load(dictFileName) as TextAsset;
        JSONObject jsonObj = (JSONObject)JSON.Parse(ta.text);

        foreach (var key in jsonObj.GetKeys())
        {
            outputDict[key] = jsonObj[key];
        }
    }
示例#3
0
    /// <summary>
    /// parses the json and creates a dictionary base on it
    /// </summary>
    private void CreateDictionary()
    {
        TextAsset  temp     = Resources.Load("MyDictionary") as TextAsset;
        string     jsonFile = temp.ToString();
        JSONObject jsonObj  = (JSONObject)JSON.Parse(jsonFile);

        foreach (var key in jsonObj.GetKeys())
        {
            gameDict[key] = jsonObj[key];
        }
    }