JPJsonStreambufferProtocol Protocol Reference
| 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
-
– flushFlush any pending bytes from internal buffer to the output device.
required method -
– write:length:Write a sequence of bytes.
required method -
– closeClose a stream-buffer.
required method -
errorReturns the error of the last operation,
property required methodnilif there was success.
Instance Methods
close
Close a stream-buffer.
- (BOOL)closeReturn 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.hflush
Flush any pending bytes from internal buffer to the output device.
- (BOOL)flushReturn Value
Returns YES on success, otherwise NO indicating an error.
Declared In
JPJsonWriterExtensions.hwrite:length:
Write a sequence of bytes.
- (BOOL)write:(const void *)buffer length:(int)lengthParameters
- 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