/// <summary> /// Gets the buffered JSON data. /// </summary> /// <returns>Returns a <see cref="JsonBuffer"/> object with the /// written and buffered JSON data.</returns> /// <remarks> /// This method method auto-completes the JSON data if it has not /// been written in its entirety. /// </remarks> public JsonBuffer GetBuffer() { if (Depth > 0) { AutoComplete(); } return(_storage.ToBuffer()); }
public static JsonBuffer From(JsonToken token) { JsonTokenClass clazz = token.Class; if (clazz == JsonTokenClass.Null) { return(_null); } if (!clazz.IsScalar) { throw new ArgumentException("Token must represent a JSON scalar value or null.", "token"); } if (clazz == JsonTokenClass.Boolean) { return(token.Equals(JsonToken.True()) ? _true : _false); } JsonBufferStorage storage = new JsonBufferStorage(1); storage.Write(token); return(storage.ToBuffer()); }
public static JsonBuffer From(JsonToken token) { JsonTokenClass clazz = token.Class; if (clazz == JsonTokenClass.Null) return _null; if (!clazz.IsScalar) throw new ArgumentException("Token must represent a JSON scalar value or null.", "token"); if (clazz == JsonTokenClass.Boolean) return token.Equals(JsonToken.True()) ? _true : _false; JsonBufferStorage storage = new JsonBufferStorage(1); storage.Write(token); return storage.ToBuffer(); }