Esempio n. 1
0
    public static string GetBody(string json)
    {
        string result;

        try
        {
            int num = json.IndexOf("resData");
            num = json.IndexOf(":", num);
            num++;
            if ("null" == json.Substring(num, "null".Length))
            {
                result = string.Empty;
            }
            else
            {
                num = json.IndexOf(":", num);
                num++;
                int    num2 = WebAPIJsonParse.SkipBody(json, num + 1);
                string text = json.Substring(num, num2 - num);
                if ("null" == text.Substring(0, "null".Length))
                {
                    result = string.Empty;
                }
                else
                {
                    result = text.Trim();
                }
            }
        }
        catch (Exception ex)
        {
            throw new JsonException(ex.ToString());
        }
        return(result);
    }
Esempio n. 2
0
    public static Dictionary <string, string> GetResponseList(List <RequestBase> requestList, string json)
    {
        Dictionary <string, string> dictionary = new Dictionary <string, string>();

        if (!string.IsNullOrEmpty(json))
        {
            int num = json.IndexOf("resData");
            if (num == -1)
            {
                throw new JsonException("json parse error : GetJsonData");
            }
            while (json.Length > num && json[num] != '{')
            {
                num++;
            }
            num++;
            while (json.Length > num)
            {
                int num2 = num;
                while (json.Length > num2 && json[num2] != '{')
                {
                    num2++;
                }
                if (json.Length <= num2)
                {
                    break;
                }
                for (int i = dictionary.Count; i < requestList.Count; i++)
                {
                    int num3 = json.IndexOf("null", num, num2 - num);
                    if (num3 != -1)
                    {
                        dictionary.Add(requestList[i].apiId, string.Empty);
                        num = num3 + "null".Length;
                    }
                }
                for (int j = dictionary.Count; j < requestList.Count; j++)
                {
                    if (json.IndexOf(requestList[j].apiId, num, num2 - num) != -1)
                    {
                        int num4 = WebAPIJsonParse.SkipBody(json, num2 + 1);
                        dictionary.Add(requestList[j].apiId, json.Substring(num2, num4 - num2).Trim());
                        num = num4;
                        break;
                    }
                }
                if (num2 == num)
                {
                    num = WebAPIJsonParse.SkipBody(json, num2 + 1);
                    global::Debug.LogWarning("WebAPIJsonParse.GetResponseList : Not Found Response");
                }
            }
        }
        return(dictionary);
    }