/// <summary> /// Creates a <see cref="SystemSettings"/> object from a JSON string /// in a byte array. /// </summary> /// <param name="json">Byte array containing a JSON string.</param> /// <returns>A <see cref="SystemSettings"/> object.</returns> public static SystemSettings FromJsonBytes(byte[] json) { using (var reader = new JsonTextReader(new StreamReader(new MemoryStream(json)))) { Check(reader.Read(), reader); Check(JsonToken.StartObject, reader); StreamAcl userStreamAcl = null; StreamAcl systemStreamAcl = null; while (true) { Check(reader.Read(), reader); if (reader.TokenType == JsonToken.EndObject) { break; } Check(JsonToken.PropertyName, reader); var name = (string)reader.Value; switch (name) { case SystemMetadata.UserStreamAcl: userStreamAcl = StreamMetadata.ReadAcl(reader); break; case SystemMetadata.SystemStreamAcl: systemStreamAcl = StreamMetadata.ReadAcl(reader); break; default: { Check(reader.Read(), reader); // skip JToken.ReadFrom(reader); break; } } } return(new SystemSettings(userStreamAcl, systemStreamAcl)); } }