Conforms to NSObject
Declared in JPJsonWriterExtensions.h

Overview

The JPJsonSerializableProtocol must be implemented for custom classes, which shall be serialized into a JSON document. By default, only the Objective-C classes specified in the mapping can be used to be serialized as JSON.

When implementing the JPJsonSerializableProtocol for a class, the objects will be serialized into their corresponding JSON element – provided the implementation meets all requirements. For example, a NSDate object could be serialized as a JSON String, while formatting the date into an appropriate date string, or an NSImage could be base64 encoded and then serialized as a JSON string, too.

Tasks

Instance Methods

JPJson_serializeTo:encoding:options:level:

An implementation shall serialize itself as a character sequence and write the characters into the stream-buffer streambuf.

- (int)JPJson_serializeTo:(id<JPJsonStreambufferProtocol>)streambuf encoding:(JPUnicodeEncoding)encoding options:(JPJsonWriterOptions)options level:(int)level

Parameters

streambuf

A stream-buffer into which the characters will be written.

encoding

The output encoding of the character sequence for the serialized object.

options

Options that tailor the format of the output.

level

The current level of the hierarchy of the object structure. This is used only when additional format characters shall be inserted into the JSON text, for example when “pretty printing”.

Return Value

Returns zero on success, otherwise an integer value indicating the error.

The character sequence shall be a valid JSON element according RFC 4627, including the appropriate syntax elements.

Declared In

JPJsonWriterExtensions.h