Example #1
0
        /// <summary> Get the next value. The value can be a Boolean, Double, Integer,
        /// JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
        /// </summary>
        /// <throws>  JSONException If syntax error. </throws>
        /// <summary>
        /// </summary>
        /// <returns> An object.
        /// </returns>
        public virtual System.Object nextValue()
        {
            char c = nextClean();

            System.String s;

            switch (c)
            {
            case '"':
            case '\'':
                return(nextString(c));

            case '{':
                back();
                return(new JSONObject(this));

            case '[':
            case '(':
                back();
                return(new JSONArray(this));
            }

            /*
             * Handle unquoted text. This could be the values true, false, or
             * null, or it can be a number. An implementation (such as this one)
             * is allowed to also accept non-standard forms.
             *
             * Accumulate characters until we reach the end of the text or a
             * formatting character.
             */

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            while (c >= ' ' && ",:]}/\\\"[{;=#".IndexOf((System.Char)c) < 0)
            {
                sb.Append(c);
                c = next();
            }
            back();

            s = sb.ToString().Trim();
            if (s.Equals(""))
            {
                throw syntaxError("Missing value");
            }
            return(JSONObject.stringToValue(s));
        }