Jsonb.Writer

Namespace: SnowBank.Data.Json.Binary · class

Implements: IDisposable

Instance that outputs Jsonb values into a binary buffer

Constructors

Writer

Writer(SliceWriter buffer)

Constructs a Writer using an already prepared SliceWriter

Writer(JsonbWriterOptions options, byte[] buffer = null)

Constructs a Writer using an optional initial buffer

Methods

Clear

void Clear()

Clears the buffer, and reset the cursor its initial position

After this call, the writer can be reused to process another document.

Dispose

void Dispose()

GetBuffer

Slice GetBuffer()

Returns a Slice pointing to the content of the buffer

Any change to the slice will change the buffer !

GetBytes

byte[] GetBytes()

Returns a byte array filled with the contents of the buffer

The buffer is copied in the byte array. And change to one will not impact the other

GetWriterUnsafe

SliceWriter GetWriterUnsafe()

Exposes the internal writer

WriteDocument

int WriteDocument(JsonValue value)

Writes a JsonValue to this buffer

Returns: Number of bytes written