BMPJsonable
Objective-C
@protocol BMPJsonable <NSObject>
Swift
protocol BMPJsonable : NSObjectProtocol
Provides methods to serialize objects to JSON strings.
-
Serializes the object implementing this protocol to a JSON string
Declaration
Objective-C
- (nullable NSString *)toJsonString:(NSError *_Nullable *_Nullable)error;
Swift
func toJsonString() throws -> String
Parameters
error
Contains an error if serialization failed. Is nil when serialization was successful.
Return Value
The serialized JSON string.
-
Creates a dictionary containing data describing the object implementing this protocol which can be used to serialize it to a JSON string.
Declaration
Objective-C
- (nonnull NSDictionary *)toJsonData;
Swift
func toJsonData() -> [AnyHashable : Any]
Return Value
A dictionary containing data describing the object implementing this protocol.
-
Converts the given JSON data into an instance of the class which is implementing this protocol.
Declaration
Objective-C
+ (nullable instancetype)fromJsonData:(nonnull NSDictionary *)jsonData error:(NSError *_Nullable *_Nullable)error;
Swift
static func fromJsonData(_ jsonData: [AnyHashable : Any]) throws -> Self
Parameters
jsonData
The JSON data which should be converted into an object.
error
Contains information about any errors which happened during deserialization if nil is returned by this method.
Return Value
An instance of the class which is implementing this protocol or nil if an error occurred.