예제 #1
0
 private JsonArray(JsonArray array, bool unmodifiable)
 {
     if (array == null)
     {
         throw new ArgumentNullException("array");
     }
     if (unmodifiable)
     {
         values = new ReadOnlyCollection<JsonValue>(array.values);
     }
     else
     {
         values = new List<JsonValue>(array.values);
     }
 }
예제 #2
0
 /// <summary>
 /// Returns an unmodifiable wrapper for the specified JsonArray. This method allows to provide read-only access to a JsonArray.
 /// The returned JsonArray is backed by the given array and reflects subsequent changes.
 /// </summary>
 /// <param name="array">the JsonArray for which an unmodifiable JsonArray is to be returned</param>
 /// <returns>an unmodifiable view of the specified JsonArray</returns>
 public static JsonArray unmodifiableArray(JsonArray array)
 {
     return new JsonArray(array, true);
 }
예제 #3
0
 /// <summary>
 /// Creates a new JsonArray with the contents of the specified JSON array.
 /// </summary>
 /// <param name="array">the JsonArray to get the initial contents from, must not be <code>null</code></param>
 public JsonArray(JsonArray array) : this(array, false) { }
예제 #4
0
 /// <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);
 }
예제 #5
0
 internal void writeArray(JsonArray array)
 {
     writeBeginArray();
     bool first = true;
     foreach (JsonValue value in array)
     {
         if (!first)
         {
             writeArrayValueSeparator();
         }
         value.write(this);
         first = false;
     }
     writeEndArray();
 }
예제 #6
0
 /// <summary>
 /// Creates a new JsonArray with the contents of the specified JSON array.
 /// </summary>
 /// <param name="array">the JsonArray to get the initial contents from, must not be <code>null</code></param>
 public JsonArray(JsonArray array) : this(array, false)
 {
 }
예제 #7
0
 /// <summary>
 /// Returns an unmodifiable wrapper for the specified JsonArray. This method allows to provide read-only access to a JsonArray.
 /// The returned JsonArray is backed by the given array and reflects subsequent changes.
 /// </summary>
 /// <param name="array">the JsonArray for which an unmodifiable JsonArray is to be returned</param>
 /// <returns>an unmodifiable view of the specified JsonArray</returns>
 public static JsonArray unmodifiableArray(JsonArray array)
 {
     return(new JsonArray(array, true));
 }
예제 #8
0
 private JsonArray readArray()
 {
     read();
     JsonArray array = new JsonArray();
     skipWhiteSpace();
     if (readChar(']'))
     {
         return array;
     }
     do
     {
         skipWhiteSpace();
         array.add(readValue());
         skipWhiteSpace();
     } while (readChar(','));
     if (!readChar(']'))
     {
         throw expected("',' or ']'");
     }
     return array;
 }