public void AddObject(JSONObject obj) { objectBuilding.Add(obj); }
public ConstructBoolean(string firstCharacter) { objBuilding = new JSONObject(); strBuilder = new StringBuilder(); strBuilder.Append(firstCharacter); }
public ConstructArray() { objectBuilding = new JSONObject(); objectBuilding.InitializeArray(); }
public JSONObject DoConstruction(string ch, JSONParser parser) { if (ch.Equals("\"")) { // finished string objectBuilding = strBuilder.ToString(); return objectBuilding; } else { strBuilder.Append(ch); } return null; }
public ConstructString() { objectBuilding = new JSONObject(); strBuilder = new StringBuilder(); }
public void AddObject(JSONObject obj) { throw new InvalidOperationException("Objects cannot be added to ConstructString construct"); }
public ConstructObject() { currentKey = null; objectBuilding = new JSONObject(); }
public void AddObject(JSONObject obj) { if (currentKey == null) { currentKey = obj; } else { objectBuilding.AddChild(currentKey, obj); currentKey = null; } }
public ConstructNull() { objBuidling = new JSONObject(); objBuidling.SetAsNull(); }
public void AddObject(JSONObject obj) { throw new InvalidOperationException("Cannot add objects to ConstructNull construct"); }
public JSONObject DoConstruction(string ch, JSONParser parser) { if (ch.Equals(",") || ch.Equals("]") || ch.Equals("}")) { // return object objBuilding = Double.Parse(strBuilder.ToString()); return objBuilding; } else { strBuilder.Append(ch); } return null; }
private bool CheckDataConsistency(JSONObject value) { // check that the value being sent in is consistent with other data points bool retval = true; if (array.Count > 0) { Console.Out.WriteLine("value type: " + value.type.ToString()); Console.Out.WriteLine("Array type: " + array[0].type.ToString()); if (value.type != array[0].type) retval = false; } return retval; }
public void AddChild(string key, JSONObject child) { if (this.type == JsonType.jobj) { this.children.Add(key, child); } }
public void Add(JSONObject child) { if (this.type == JsonType.jarr) { this.array.Add(child); } }
/// <summary> /// Returns the child by index. If the index is greater than the current count, add a new object at the largest index. /// </summary> /// <param name="key">Index to get the child</param> /// <returns>The child at the index, or a new child at the largest index</returns> public JSONObject this[int key] { get { if (array != null) { if (key < array.Count) { return array[key]; } else { array.Add(new JSONObject()); return array[array.Count - 1]; } } return null; } set { if (array != null) { if (CheckDataConsistency(value)) { if (key < array.Count) array[key] = value; else { JSONObject jo = new JSONObject(); jo = value; array.Add(jo); } } else { throw new ArrayTypeMismatchException("Cannot add value " + value.ToString() + " to data array"); } } } }