/// <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; } }
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 {} }
public void addJSONValue(JSONValue obj) { value[len++] = obj; }
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 ""; }
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); }
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)); }
public JSON(JSONValue val) { this.val = val; }
public void AddValue(JSONValue val) { m_Vals.Add(val); }
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)); }
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)); }
private JSONValue extraRequestedInThePastToJSON() { JSONValue generated_boolean_RequestedInThePast = (storeRequestedInThePast ? (JSONValue) new JSONTrueValue() : (JSONValue) new JSONFalseValue()); return(generated_boolean_RequestedInThePast); }
public virtual JSONValue extraTimeOfMoonPhaseInformationNuggetLookup(string field_name) { JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null); return(result); }
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)); }
public virtual JSONValue extraCarControlSeatHeaterCommandLookup(string field_name) { JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null); return(result); }
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()); }
public void Value(JSONValue val) { Debug.Assert(mElementStack.Peek().Type == ElementType.Array); CheckParentSeparator(); mWriter.Write(val.Encoded); mElementStack.Peek().PastFirst = true; }
public virtual JSONValue extraUberApiErrorPromoFailedLookup(string field_name) { JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null); return(result); }
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); }
public virtual JSONValue extraTimerLookup(string field_name) { JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null); return(result); }
public static TimerJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete) { return(from_json(json_value, ignore_extras, allow_incomplete, false)); }
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); }
public virtual JSONValue extraEnableCallByNameModeCommandLookup(string field_name) { JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null); return(result); }
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)); }
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); }
public virtual JSONValue extraSportsOlympicsEventSchedulesAndResultsQueryStateLookup(string field_name) { JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null); return(result); }
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); }
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); }
public virtual JSONValue extraUberRequestLocationLookup(string field_name) { JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null); return(result); }
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); } }
public void addStringValue(JSONString key, JSONValue val) { keys[len] = key; vals[len] = val; len++; }
public static SportsOlympicsEventSchedulesAndResultsQueryStateJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete) { return(from_json(json_value, ignore_extras, allow_incomplete, false)); }
/** 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; }
public void boolean(bool v) { val = new JSONBoolean(); ((JSONBoolean)val).val = v; }
public void AddPair(string name,JSONValue val) { }
public void str(string v) { val = new JSONString(); ((JSONString)val).val = v; }
public static SportsPlayoffSpecialGameContainerJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete) { return(from_json(json_value, ignore_extras, allow_incomplete, false)); }
public static UberRequestLocationJSON from_json(JSONValue json_value, bool ignore_extras, bool allow_incomplete) { return(from_json(json_value, ignore_extras, allow_incomplete, false)); }
public void num(double v) { val = new JSONNumber(); ((JSONNumber)val).val = v; }
public virtual JSONValue extraSportsPlayoffSpecialGameContainerLookup(string field_name) { JSONValue result = (extraIndex.ContainsKey(field_name) ? extraIndex[field_name] : null); return(result); }
public void vec3(Vector3 v) { val = new JSONObject(); this["x"].num (v.x); this["y"].num (v.y); this["z"].num (v.z); }
public override void extraPhoneCommandAppendPair(string key, JSONValue new_component) { extraEnableCallByNameModeCommandAppendPair(key, new_component); }
public override void extraPhoneCommandSetField(string key, JSONValue new_component) { extraEnableCallByNameModeCommandSetField(key, new_component); }
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)); }
//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); }