Conforms to NSObject
Declared in JPJsonWriterExtensions.h

Overview

JPJsonStreambufferProtocol defines the interface for a stream-buffer:

Custom classes which map to a JSON primitive element will use the stream-buffer in their implementation of method JPJson_serializeTo:encoding:options:level: in order to serialize itself into the stream. (Custom classes for JSON containers, like array and object will instead use the predefined class methods serializeObjectAsJSONArray and serializeObjectAsJSONObject).

Caution: Preliminary. At a later version this protocol may change, supporting a higher level abstraction of “stream” instead of “buffer”.

Tasks

  • – flush

    Flush any pending bytes from internal buffer to the output device.

    required method
  • – write:length:

    Write a sequence of bytes.

    required method
  • – close

    Close a stream-buffer.

    required method
  •   error

    Returns the error of the last operation, nil if there was success.

    property required method

Properties

error

Returns the error of the last operation, nil if there was success.

@property (nonatomic, readonly) NSError *error

Return Value

Returns the error of the last operation, nil if there was success.

Declared In

JPJsonWriterExtensions.h

Instance Methods

close

Close a stream-buffer.

- (BOOL)close

Return Value

Returns YES on success, otherwise NO indicating an error.

Discussion

Write any remaining bytes to the output device and close it.

Declared In

JPJsonWriterExtensions.h

flush

Flush any pending bytes from internal buffer to the output device.

- (BOOL)flush

Return Value

Returns YES on success, otherwise NO indicating an error.

Declared In

JPJsonWriterExtensions.h

write:length:

Write a sequence of bytes.

- (BOOL)write:(const void *)buffer length:(int)length

Parameters

buffer

A pointer to the sequence of bytes to be written.

length

The number of bytes to write.

Return Value

Returns YES on success, otherwise NO indicating an error.

Discussion

Write length bytes from the array of bytes pointed to by buffer into the stream-buffer. This may block the current thread until after the requested number of bytes have been written.

Declared In

JPJsonWriterExtensions.h