private JsonObject readObject() { read(); JsonObject obj = new JsonObject(); skipWhiteSpace(); if (readChar('}')) { return(obj); } do { skipWhiteSpace(); string name = readName(); skipWhiteSpace(); if (!readChar(':')) { throw expected("':'"); } skipWhiteSpace(); obj.add(name, readValue()); skipWhiteSpace(); } while (readChar(',')); if (!readChar('}')) { throw expected("',' or '}'"); } return(obj); }
internal JsonObject toArray() { JsonObject data = new JsonObject() .add("snaktype", this.type) .add("property", this.propertyId.getPrefixedId()); if (this.dataValue != null) { data.add("datavalue", this.dataValue.fullEncode()); } return data; }
public void Send(string message) { JsonObject jsonMessage = new JsonObject(); jsonMessage.add("type", "metrics").add("message", message); metricsws.Send(jsonMessage.ToString()); }
/// <summary> /// Save the reference. /// </summary> /// <param name="summary">The summary</param> public void save(string summary) { if (this.statement.id == null) { throw new Exception("The statement has no Id. Please save the statement containing it first."); } JsonObject obj = new JsonObject(); foreach (KeyValuePair<string, Dictionary<string, Snak>> pair in this.snaks) { JsonArray array = new JsonArray(); foreach(KeyValuePair<string, Snak> p in pair.Value) { array.add(p.Value.toArray()); } obj.add(pair.Key, array); } JsonObject result = this.statement.entity.api.setReference(this.statement.id, obj, this.hash, this.statement.entity.lastRevisionId, summary); this.updateDataFromResult(result); }
private JsonObject readObject() { read(); JsonObject obj = new JsonObject(); skipWhiteSpace(); if (readChar('}')) { return obj; } do { skipWhiteSpace(); string name = readName(); skipWhiteSpace(); if (!readChar(':')) { throw expected("':'"); } skipWhiteSpace(); obj.add(name, readValue()); skipWhiteSpace(); } while (readChar(',')); if (!readChar('}')) { throw expected("',' or '}'"); } return obj; }