예제 #1
0
파일: JSON.cs 프로젝트: ploxolq/Unreal.FGO
 public static object JsonDecode(string sJSON, out JSON.JSONParseErrors oErrors)
 {
     oErrors = new JSON.JSONParseErrors
     {
         iErrorIndex  = -1,
         sWarningText = string.Empty
     };
     if (!string.IsNullOrEmpty(sJSON))
     {
         char[] json = sJSON.ToCharArray();
         int    num  = 0;
         bool   flag = true;
         return(JSON.ParseValue(json, ref num, ref flag, ref oErrors));
     }
     return(null);
 }
예제 #2
0
파일: JSON.cs 프로젝트: ploxolq/Unreal.FGO
        private static ArrayList ParseArray(char[] json, ref int index, ref JSON.JSONParseErrors oErrors)
        {
            ArrayList arrayList = new ArrayList();

            JSON.NextToken(json, ref index);
            bool flag = false;

            while (!flag)
            {
                JSON.JSONTokens jSONTokens = JSON.LookAhead(json, index);
                if (jSONTokens == JSON.JSONTokens.NONE)
                {
                    if (oErrors.iErrorIndex < 0)
                    {
                        oErrors.iErrorIndex = index;
                    }
                    return(null);
                }
                if (jSONTokens == JSON.JSONTokens.COMMA)
                {
                    JSON.NextToken(json, ref index);
                }
                else
                {
                    if (jSONTokens == JSON.JSONTokens.SQUARED_CLOSE)
                    {
                        JSON.NextToken(json, ref index);
                        return(arrayList);
                    }
                    bool   flag2 = true;
                    object value = JSON.ParseValue(json, ref index, ref flag2, ref oErrors);
                    if (!flag2)
                    {
                        if (oErrors.iErrorIndex < 0)
                        {
                            oErrors.iErrorIndex = index;
                        }
                        return(null);
                    }
                    arrayList.Add(value);
                }
            }
            return(arrayList);
        }
예제 #3
0
파일: JSON.cs 프로젝트: ploxolq/Unreal.FGO
        private static string ParseUnquotedIdentifier(char[] json, ref int index, ref JSON.JSONParseErrors oErrors)
        {
            JSON.EatWhitespace(json, ref index);
            int           num           = index;
            StringBuilder stringBuilder = new StringBuilder(2048);
            bool          flag          = false;

            while (!flag)
            {
                if (index != json.Length)
                {
                    char c = json[index];
                    if (JSON.isValidIdentifierChar(c))
                    {
                        stringBuilder.Append(c);
                        index++;
                        continue;
                    }
                    if (stringBuilder.Length < 1)
                    {
                        return(null);
                    }
                    flag = true;
                }
IL_4D:
                if (!flag)
                {
                    return(null);
                }
                oErrors.sWarningText = string.Format("{0}Illegal/Unquoted identifier '{1}' at position {2}.\n", oErrors.sWarningText, stringBuilder.ToString(), num);
                return(stringBuilder.ToString());
            }
            if (!flag)
            {
                return(null);
            }
            oErrors.sWarningText = string.Format("{0}Illegal/Unquoted identifier '{1}' at position {2}.\n", oErrors.sWarningText, stringBuilder.ToString(), num);
            return(stringBuilder.ToString());
        }
예제 #4
0
파일: JSON.cs 프로젝트: ploxolq/Unreal.FGO
        private static Hashtable ParseObject(char[] json, ref int index, ref JSON.JSONParseErrors oErrors)
        {
            Hashtable hashtable = new Hashtable();

            JSON.NextToken(json, ref index);
            bool flag = false;

            while (!flag)
            {
                JSON.JSONTokens jSONTokens = JSON.LookAhead(json, index);
                if (jSONTokens == JSON.JSONTokens.NONE)
                {
                    return(null);
                }
                if (jSONTokens == JSON.JSONTokens.COMMA)
                {
                    JSON.NextToken(json, ref index);
                }
                else
                {
                    if (jSONTokens == JSON.JSONTokens.CURLY_CLOSE)
                    {
                        JSON.NextToken(json, ref index);
                        return(hashtable);
                    }
                    string text;
                    if (jSONTokens == JSON.JSONTokens.IMPLIED_IDENTIFIER_NAME)
                    {
                        text = JSON.ParseUnquotedIdentifier(json, ref index, ref oErrors);
                        if (text == null)
                        {
                            if (oErrors.iErrorIndex < 0)
                            {
                                oErrors.iErrorIndex = index;
                            }
                            return(null);
                        }
                    }
                    else
                    {
                        text = JSON.ParseString(json, ref index);
                        if (text == null)
                        {
                            if (oErrors.iErrorIndex < 0)
                            {
                                oErrors.iErrorIndex = index;
                            }
                            return(null);
                        }
                    }
                    jSONTokens = JSON.NextToken(json, ref index);
                    if (jSONTokens != JSON.JSONTokens.COLON)
                    {
                        if (oErrors.iErrorIndex < 0)
                        {
                            oErrors.iErrorIndex = index;
                        }
                        return(null);
                    }
                    bool   flag2 = true;
                    object value = JSON.ParseValue(json, ref index, ref flag2, ref oErrors);
                    if (!flag2)
                    {
                        oErrors.iErrorIndex = index;
                        return(null);
                    }
                    hashtable[text] = value;
                }
            }
            return(hashtable);
        }
예제 #5
0
파일: JSON.cs 프로젝트: ploxolq/Unreal.FGO
        private static object ParseValue(char[] json, ref int index, ref bool success, ref JSON.JSONParseErrors oErrors)
        {
            switch (JSON.LookAhead(json, index))
            {
            case JSON.JSONTokens.CURLY_OPEN:
                return(JSON.ParseObject(json, ref index, ref oErrors));

            case JSON.JSONTokens.SQUARED_OPEN:
                return(JSON.ParseArray(json, ref index, ref oErrors));

            case JSON.JSONTokens.STRING:
                return(JSON.ParseString(json, ref index));

            case JSON.JSONTokens.NUMBER:
                return(JSON.ParseNumber(json, ref index));

            case JSON.JSONTokens.TRUE:
                JSON.NextToken(json, ref index);
                return(true);

            case JSON.JSONTokens.FALSE:
                JSON.NextToken(json, ref index);
                return(false);

            case JSON.JSONTokens.NULL:
                JSON.NextToken(json, ref index);
                return(null);

            case JSON.JSONTokens.IMPLIED_IDENTIFIER_NAME:
                return(JSON.ParseUnquotedIdentifier(json, ref index, ref oErrors));
            }
            success = false;
            return(null);
        }