Example #1
0
        /// <summary>
        ///     Construct a copy of the JSONValue given as a parameter
        /// </summary>
        /// <param name="value"></param>
        public JSONValue(JSONValue value)
        {
            Type = value.Type;
            switch (Type)
            {
                case JSONValueType.String:
                    Str = value.Str;
                    break;

                case JSONValueType.Boolean:
                    Boolean = value.Boolean;
                    break;

                case JSONValueType.Number:
                    Number = value.Number;
                    break;

                case JSONValueType.Object:
                    if (value.Obj != null)
                        Obj = new JSONObject(value.Obj);
                    break;

                case JSONValueType.Array:
                    Array = new JSONArray(value.Array);
                    break;
            }
        }
Example #2
0
 public JSONValue decode(string str)
 {
     int index = 0;
     index = passWhiteSpace(str, index);
     if (str[index] == '[')
         this.json = decodeArray(str, ref index);
     if (str[index] == '{')
         this.json = decodeObject(str, ref index);
     return this.json;
 }
 //Getter/Setter for Object
 public JSON this[string key]
 {
     get {
         if(val is JSONObject) {
             JSONObject obj = (JSONObject)val;
             if(obj.elements.ContainsKey(key)) {
                 return obj.elements[key];
             }
             else {
                 JSON newObj = new JSON(new JSONObject());
                 obj.elements.Add(key, newObj);
                 return newObj;
             }
         }
         else {
             val = new JSONObject();
             JSONObject obj = (JSONObject)val;
             JSON newObj = new JSON(new JSONObject());
             obj.elements.Add(key, newObj);
             return newObj;
         }
     }
     set {}
 }
 //Getter/Setter for Array
 public JSON this[int key]
 {
     get {
         if(val is JSONArray) {
             JSONArray obj = (JSONArray)val;
             if(obj.elements.Count > key) {
                 return obj.elements[key];
             }
             else {
                 JSON newObj = new JSON(new JSONArray());
                 obj.elements[key] = newObj;
                 return newObj;
             }
         }
         else {
             val = new JSONArray();
             JSONArray obj = (JSONArray)val;
             JSON newObj = new JSON(new JSONArray());
             obj.elements[key] = newObj;
             return newObj;
         }
     }
     set {}
 }
Example #5
0
 public void addJSONValue(JSONValue obj)
 {
     value[len++] = obj;
 }
Example #6
0
        public string dumpValue(JSONValue val)
        {
            if (val is JSONString)
            {
                return "\'" + ((JSONString)val).str + "\'";
            }
            if (val is JSONNull)
            {
                return "null";
            }
            if (val is JSONBool)
            {
                if (((JSONBool)val).val)
                {
                    return "true";
                }
                else
                {
                    return "false";
                }
            }
            if (val is JSONArray)
            {
                return dumpArray((JSONArray)val);
            }
            if (val is JSONObject)
            {
                return dumpObject((JSONObject)val);
            }

            if (val is JSONNumber)
            {
                return ((JSONNumber)val).val.ToString();
            }
            return "";
        }
Example #7
0
 private void  fromJSONComputerData(JSONValue json_value, bool ignore_extras)
   {
     Debug.Assert(json_value != null);
     BattleshipPlayerDataJSON convert_classy = BattleshipPlayerDataJSON.from_json(json_value, ignore_extras, true);
     setComputerData(convert_classy);
   }
Example #8
0
 public virtual JSONValue extraBattleshipPlayCommandLookup(string field_name)
   {
     JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null);
     return result;
   }
 public static new HomeAutomationSetVolumeDeltaCommandJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete)
 {
     return(from_json(json_value, ignore_extras, allow_incomplete, false));
 }
Example #10
0
 public JSON(JSONValue val)
 {
     this.val = val;
 }
Example #11
0
 public void AddValue(JSONValue val)
 {
     m_Vals.Add(val);
 }
Example #12
0
 public static new UberApiErrorPromoFailedJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete)
 {
     return(from_json(json_value, ignore_extras, allow_incomplete, false));
 }
Example #13
0
 public static new TimeOfMoonPhaseInformationNuggetJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete)
 {
     return(from_json(json_value, ignore_extras, allow_incomplete, false));
 }
Example #14
0
    private JSONValue  extraRequestedInThePastToJSON()
    {
        JSONValue generated_boolean_RequestedInThePast = (storeRequestedInThePast ? (JSONValue) new JSONTrueValue() : (JSONValue) new JSONFalseValue());

        return(generated_boolean_RequestedInThePast);
    }
Example #15
0
    public virtual JSONValue extraTimeOfMoonPhaseInformationNuggetLookup(string field_name)
    {
        JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null);

        return(result);
    }
Example #16
0
 public static new CarControlSeatHeaterCommandJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete)
 {
     return(from_json(json_value, ignore_extras, allow_incomplete, false));
 }
Example #17
0
    public virtual JSONValue extraCarControlSeatHeaterCommandLookup(string field_name)
    {
        JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null);

        return(result);
    }
Example #18
0
        private void sendGameMessage(String name, Vector2 value)
        {
            JSONValue val;
            String output;

            val = new JSONValue();
            val.Name = name;
            val.putVector2(value);

            output = JsonConvert.SerializeObject(val);
            //handler.SendGameMessage(output, nGame.getId());
        }
Example #19
0
        public void Value(JSONValue val)
        {
            Debug.Assert(mElementStack.Peek().Type == ElementType.Array);

            CheckParentSeparator();
            mWriter.Write(val.Encoded);

            mElementStack.Peek().PastFirst = true;
        }
Example #20
0
    public virtual JSONValue extraUberApiErrorPromoFailedLookup(string field_name)
    {
        JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null);

        return(result);
    }
Example #21
0
    private void  fromJSONCommandType(JSONValue json_value, bool ignore_extras)
    {
        Debug.Assert(json_value != null);
        JSONStringValue json_string = json_value.string_value();

        if (json_string == null)
        {
            throw new Exception("The value for field CommandType of CarControlSeatHeaterCommandJSON is not a string.");
        }
        TypeCommandType the_enum;

        switch (json_string.getData()[0])
        {
        case 'S':
            if (String.Compare(json_string.getData(), 1, "et", 0, 2, false) == 0)
            {
                switch (json_string.getData()[3])
                {
                case 'H':
                    if (String.Compare(json_string.getData(), 4, "igh", 0, 3, false) == 0)
                    {
                        if (json_string.getData().Length == 7)
                        {
                            {
                                the_enum = TypeCommandType.CommandType_SetHigh;
                                goto enum_is_done;
                            }
                        }
                        switch (json_string.getData()[7])
                        {
                        case 'e':
                            if ((String.Compare(json_string.getData(), 8, "r", 0, 1, false) == 0) && (json_string.getData().Length == 9))
                            {
                                the_enum = TypeCommandType.CommandType_SetHigher;
                                goto enum_is_done;
                            }
                            break;

                        default:
                            break;
                        }
                    }
                    break;

                case 'L':
                    if (String.Compare(json_string.getData(), 4, "ow", 0, 2, false) == 0)
                    {
                        if (json_string.getData().Length == 6)
                        {
                            {
                                the_enum = TypeCommandType.CommandType_SetLow;
                                goto enum_is_done;
                            }
                        }
                        switch (json_string.getData()[6])
                        {
                        case 'e':
                            if ((String.Compare(json_string.getData(), 7, "r", 0, 1, false) == 0) && (json_string.getData().Length == 8))
                            {
                                the_enum = TypeCommandType.CommandType_SetLower;
                                goto enum_is_done;
                            }
                            break;

                        default:
                            break;
                        }
                    }
                    break;

                case 'M':
                    if ((String.Compare(json_string.getData(), 4, "edium", 0, 5, false) == 0) && (json_string.getData().Length == 9))
                    {
                        the_enum = TypeCommandType.CommandType_SetMedium;
                        goto enum_is_done;
                    }
                    break;

                default:
                    break;
                }
            }
            break;

        case 'T':
            if (String.Compare(json_string.getData(), 1, "urnO", 0, 4, false) == 0)
            {
                switch (json_string.getData()[5])
                {
                case 'f':
                    if ((String.Compare(json_string.getData(), 6, "f", 0, 1, false) == 0) && (json_string.getData().Length == 7))
                    {
                        the_enum = TypeCommandType.CommandType_TurnOff;
                        goto enum_is_done;
                    }
                    break;

                case 'n':
                    if (json_string.getData().Length == 6)
                    {
                        the_enum = TypeCommandType.CommandType_TurnOn;
                        goto enum_is_done;
                    }
                    break;

                default:
                    break;
                }
            }
            break;

        default:
            break;
        }
        throw new Exception("The value for field CommandType of CarControlSeatHeaterCommandJSON is not one of the legal strings.");
        enum_is_done :;
        setCommandType(the_enum);
    }
Example #22
0
    public virtual JSONValue extraTimerLookup(string field_name)
    {
        JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null);

        return(result);
    }
Example #23
0
 public static TimerJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete)
 {
     return(from_json(json_value, ignore_extras, allow_incomplete, false));
 }
Example #24
0
    public static new SportsOlympicsEventSchedulesAndResultsInformationNuggetJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete, bool allow_unpolished)
    {
        SportsOlympicsEventSchedulesAndResultsInformationNuggetJSON result;

        {
            HoldingGenerator generator = new HoldingGenerator("Type SportsOlympicsEventSchedulesAndResultsInformationNugget", ignore_extras);
            generator.set_allow_incomplete(allow_incomplete);
            generator.set_allow_unpolished(allow_unpolished);
            if (allow_incomplete || allow_unpolished)
            {
                json_value.write(generator);
            }
            else
            {
                json_value.write(generator);
            }
            Debug.Assert(generator.have_value);
            result = generator.value;
        };
        return(result);
    }
Example #25
0
    public virtual JSONValue extraEnableCallByNameModeCommandLookup(string field_name)
    {
        JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null);

        return(result);
    }
Example #26
0
 public static new SportsOlympicsEventSchedulesAndResultsInformationNuggetJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete)
 {
     return(from_json(json_value, ignore_extras, allow_incomplete, false));
 }
Example #27
0
   public static new BattleshipPlayCommandJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete)
 {
   return from_json(json_value, ignore_extras, allow_incomplete, false);
 }
Example #28
0
    public virtual JSONValue extraSportsOlympicsEventSchedulesAndResultsQueryStateLookup(string field_name)
    {
        JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null);

        return(result);
    }
Example #29
0
 private void  fromJSONStartDateAndOrTime(JSONValue json_value, bool ignore_extras)
   {
     Debug.Assert(json_value != null);
     DateAndOrTimeJSON convert_classy = DateAndOrTimeJSON.from_json(json_value, ignore_extras, true);
     setStartDateAndOrTime(convert_classy);
   }
Example #30
0
    public virtual void extraSportsOlympicsEventSchedulesAndResultsQueryStateAppendPair(string key, JSONValue new_component)
    {
        Debug.Assert(key != null);
        Debug.Assert(new_component != null);

        Debug.Assert(extraKeys.Count == extraValues.Count);
        extraKeys.Add(key);
        extraValues.Add(new_component);
        extraIndex.Add(key, new_component);
    }
Example #31
0
    public virtual JSONValue extraUberRequestLocationLookup(string field_name)
    {
        JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null);

        return(result);
    }
Example #32
0
    public virtual void extraSportsOlympicsEventSchedulesAndResultsQueryStateSetField(string key, JSONValue new_component)
    {
        Debug.Assert(key != null);
        Debug.Assert(new_component != null);

        JSONValue old_field = extraSportsOlympicsEventSchedulesAndResultsQueryStateLookup(key);

        if (old_field == null)
        {
            extraSportsOlympicsEventSchedulesAndResultsQueryStateAppendPair(key, new_component);
        }
        else
        {
            int count = extraKeys.Count;
            Debug.Assert(count == extraValues.Count);
            for (int num = 0; num < count; ++num)
            {
                if (extraKeys[num].Equals(key))
                {
                    extraValues[num] = new_component;
                    break;
                }
            }
            extraIndex.Add(key, new_component);
        }
    }
Example #33
0
 public void addStringValue(JSONString key, JSONValue val)
 {
     keys[len] = key;
     vals[len] = val;
     len++;
 }
Example #34
0
 public static SportsOlympicsEventSchedulesAndResultsQueryStateJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete)
 {
     return(from_json(json_value, ignore_extras, allow_incomplete, false));
 }
Example #35
0
 /** Add a field to the current parent object. */
 public void Field(String key, JSONValue val)
 {
     Debug.Assert(mElementStack.Peek().Type == ElementType.Object);
     AddFieldKey(key);
     mWriter.Write("{0}", val.Encoded);
     mElementStack.Peek().PastFirst = true;
 }
Example #36
0
 public void boolean(bool v)
 {
     val = new JSONBoolean();
     ((JSONBoolean)val).val = v;
 }
Example #37
0
        public void AddPair(string name,JSONValue val)
        {

        }
Example #38
0
 public void str(string v)
 {
     val = new JSONString();
     ((JSONString)val).val = v;
 }
Example #39
0
 public static SportsPlayoffSpecialGameContainerJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete)
 {
     return(from_json(json_value, ignore_extras, allow_incomplete, false));
 }
Example #40
0
 public static UberRequestLocationJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete)
 {
     return(from_json(json_value, ignore_extras, allow_incomplete, false));
 }
Example #41
0
 public void num(double v)
 {
     val = new JSONNumber();
     ((JSONNumber)val).val = v;
 }
Example #42
0
    public virtual JSONValue extraSportsPlayoffSpecialGameContainerLookup(string field_name)
    {
        JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null);

        return(result);
    }
Example #43
0
 public void vec3(Vector3 v)
 {
     val = new JSONObject();
     this["x"].num (v.x);
     this["y"].num (v.y);
     this["z"].num (v.z);
 }
Example #44
0
 public override void extraPhoneCommandAppendPair(string key, JSONValue new_component)
 {
     extraEnableCallByNameModeCommandAppendPair(key, new_component);
 }
Example #45
0
 public override void extraPhoneCommandSetField(string key, JSONValue new_component)
 {
     extraEnableCallByNameModeCommandSetField(key, new_component);
 }
Example #46
0
 public static new EnableCallByNameModeCommandJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete)
 {
     return(from_json(json_value, ignore_extras, allow_incomplete, false));
 }
Example #47
0
    //Appender for Array
    public JSON Append(JSON add)
    {
        //Convert to JSONArray if not
        if(!(val is JSONArray)) {
            val = new JSONArray();
        }

        JSONArray arr = (JSONArray)val;
        arr.elements.Add(add);
        return this;
    }
    public virtual void extraHomeAutomationSetVolumeDeltaCommandAppendPair(string key, JSONValue new_component)
    {
        Debug.Assert(key != null);
        Debug.Assert(new_component != null);

        Debug.Assert(extraKeys.Count == extraValues.Count);
        extraKeys.Add(key);
        extraValues.Add(new_component);
        extraIndex.Add(key, new_component);
    }