ObjFW
Instance Methods | List of all members
<OFJSONRepresentation> Protocol Reference

A protocol implemented by classes that support encoding to a JSON representation. More...

#import <OFJSONRepresentation.h>

Inheritance diagram for <OFJSONRepresentation>:
OFArray OFDictionary OFNull OFNumber OFString OFMutableArray OFMutableDictionary OFConstantString OFMutableString

Instance Methods

(OFString *) - JSONRepresentation
 Returns the JSON representation of the object as a string. More...
 
(OFString *) - JSONRepresentationWithOptions:
 Returns the JSON representation of the object as a string. More...
 

Detailed Description

A protocol implemented by classes that support encoding to a JSON representation.

OFJSONRepresentation.h ObjFW/OFJSONRepresentation.h

Warning
Although this method can be called directly on classes other than OFArray and OFDictionary, this will generate invalid JSON, as JSON requires all data to be encapsulated in an array or a dictionary!

Method Documentation

◆ JSONRepresentation()

- (OFString *) JSONRepresentation

Returns the JSON representation of the object as a string.

Returns
The JSON representation of the object as a string

◆ JSONRepresentationWithOptions:()

- (OFString *) JSONRepresentationWithOptions: (int)  options

Returns the JSON representation of the object as a string.

Parameters
optionsThe options to use when creating a JSON representation.
Possible values are:
Value Description
OF_JSON_REPRESENTATION_PRETTY Optimize for readability
OF_JSON_REPRESENTATION_JSON5 Generate JSON5
Returns
The JSON representation of the object as a string

The documentation for this protocol was generated from the following file: