![]() |
Diffusion Apple API 6.11.5
Unified Client Library for iOS, tvOS and OS X / macOS
|
An immutable JSON value with support for both binary and JSON deltas.
JSON is "JavaScript Object Notation", a lightweight data-interchange format. See www.json.org.
Internally the value is stored and transmitted not as a JSON string, but in CBOR format to reduce memory and network overhead. CBOR (Concise Binary Object Representation) is a standardized format for binary representation of structured data defined by RFC 7049. See www.cbor.io.
Each JSON value is represented as a single CBOR data item. CBOR supports composite data types just like JSON, so this data item can be an array or a map of other data items. The null
value is represented by the CBOR Null
value.
Properties | |
PTDiffusionRequest * | request |
PTDiffusionResponse * | response |
PTDiffusionUpdateConstraint * | updateConstraint |
![]() | |
NSData * | data |
Instance Methods | |
(nullable instancetype) | - initWithObject:error: |
(nullable instancetype) | - initWithJSONData:error: |
(nullable instancetype) | - initWithJSONString:error: |
(nullable PTDiffusionBinaryDelta *) | - binaryDiffFromJSON:error: |
(nullable PTDiffusionJSON *) | - applyDelta:error: |
(BOOL) | - validateWithError: |
(nullable id) | - objectWithError: |
(nullable NSData *) | - JSONDataWithError: |
(BOOL) | - isEqualToJSON: |
![]() | |
(instancetype) | - initWithData: |
(BOOL) | - isEqualToBytes: |
- (nullable PTDiffusionJSON *) applyDelta: | (PTDiffusionBinaryDelta *) | delta | |
error: | (NSError **) | error | |
Apply a binary delta to the receiver's JSON value to create a new value.
delta | The delta describing the changes to be applied to the receiver's value in order to create the value to be returned. |
error | If an error occurs, upon return contains an NSError object that describes the problem. |
nil
if there was an error (e.g. the receiver does not represent a valid JSON value).NSInvalidArgumentException | Raised if the delta argument is `nil`. |
- (nullable PTDiffusionBinaryDelta *) binaryDiffFromJSON: | (PTDiffusionJSON *) | json | |
error: | (NSError **) | error | |
Compare the receiver's JSON value with another (e.g. an earlier version) to create a binary delta.
json | The original to which the delta should be able to be applied in order to generate the value represented by the receiver. |
error | If an error occurs, upon return contains an NSError object that describes the problem. |
nil
if there was an error (e.g. either the original or the receiver don't represent a valid JSON value).NSInvalidArgumentException | Raised if the json argument is `nil`. |
- (nullable instancetype) initWithJSONData: | (NSData *) | jsonData | |
error: | (NSError **) | error | |
Convenience wrapper around initWithObject:error: that first uses NSJSONSerialization to generate the object to be serialized.
jsonData | A data object containing JSON data. See Apple's NSJSONSerialization documentation for detailed information regarding supported encodings. |
error | If this method returns nil to indicate that an error occurred then this will be populated with the reason for that failure. |
NSInvalidArgumentException | Raised if the `jsonData` argument is `nil`. |
- (nullable instancetype) initWithJSONString: | (NSString *) | jsonString | |
error: | (NSError **) | error | |
Convenience wrapper around initWithJSONData:error: that first encodes the given string as UTF-8 (NSUTF8StringEncoding), requiring lossless conversion.
jsonString | A JSON string. |
error | If this method returns nil to indicate that an error occurred then this will be populated with the reason for that failure. |
NSInvalidArgumentException | Raised if the `jsonString` argument is `nil`. |
- (nullable instancetype) initWithObject: | (id) | object | |
error: | (NSError **) | error | |
Return a JSON object initialized with the given object.
Object hierarchies passed to this method must be constructed from Foundation objects which can be logically encoded with CBOR. This provides flexibility above and beyond the basic capabilities of a 'pure JSON' encoding as well as being less restrictive than the capabilities of NSJSONSerialization.
This means:
NSString
, NSData
, NSNumber
, NSArray
, NSDictionary
or NSNull
.Being more permissive than NSJSONSerialization in that:
NSData
instances may be used.NSString
.NSArray
or NSDictionary
).Applications may take advantage of the more permissive nature of the underlying CBOR encoding by using these capabilities, assuming:
object | The object to be serialized to CBOR and stored internally to represent the receiver. |
error | If this method returns nil to indicate that an error occurred then this will be populated with the reason for that failure. |
NSInvalidArgumentException | Raised if the `object` argument is `nil`. |
- (BOOL) isEqualToJSON: | (nullable PTDiffusionJSON *) | json |
Compares the receiver to the given JSON.
json | The JSON object with which to compare the receiver. |
YES
if the data in json is equal to the contents of the receiver, otherwise NO
.- (nullable NSData *) JSONDataWithError: | (NSError **) | error |
Convenience wrapper around objectError: that then uses NSJSONSerialization to generate the JSON data.
error | If an error occurs, upon return contains an NSError object that describes the problem. |
nil
if there was an error (e.g. the receive doesn't represent a valid JSON value or cannot be converted to pure JSON).- (nullable id) objectWithError: | (NSError **) | error |
Creates a Foundation object from the receiver's JSON value.
error | If an error occurs, upon return contains an NSError object that describes the problem. |
nil
if there was an error (e.g. the receiver doesn't represent a valid JSON value).+ (PTDiffusionRequestHandler *) requestHandlerWithDelegate: | (id< PTDiffusionJSONRequestDelegate >) | delegate |
Creates a request handler capable of receiving JSON requests for a handler registered at the server.
delegate | The object which will handle the incoming requests. A weak reference is maintained to this object by the returned handler. |
NSInvalidArgumentException | Raised if the delegate argument is `nil`. |
+ (PTDiffusionRequestStream *) requestStreamWithDelegate: | (id< PTDiffusionJSONRequestStreamDelegate >) | delegate |
Creates a request stream capable of receiving JSON requests.
delegate | The object which will handle the incoming requests. A weak reference is maintained to this object by the returned stream. |
NSInvalidArgumentException | Raised if the delegate argument is `nil`. |
+ (PTDiffusionSessionResponseStream *) sessionResponseStreamWithDelegate: | (id< PTDiffusionJSONSessionResponseStreamDelegate >) | delegate |
Creates a response stream capable of receiving JSON responses from discrete sessions.
delegate | The object which will handle the incoming responses. A weak reference is maintained to this object by the returned stream. |
NSInvalidArgumentException | Raised if the delegate argument is `nil`. |
+ (PTDiffusionValueStream *) timeSeriesEventValueStreamWithDelegate: | (id< PTDiffusionJSONTimeSeriesEventValueStreamDelegate >) | delegate |
Creates a value stream capable of receiving JSON time series events.
delegate | The object which will handle the incoming stream. A weak reference is maintained to this object by the returned stream. |
NSInvalidArgumentException | Raised if the delegate argument is `nil`. |
- (BOOL) validateWithError: | (NSError **) | error |
Check whether the receiver is valid.
error | If not valid, upon return contains an NSError object that describes the problem. |
YES
if this instance is valid.+ (PTDiffusionValueStream *) valueStreamWithDelegate: | (id< PTDiffusionJSONValueStreamDelegate >) | delegate |
Creates a value stream capable of receiving JSON values.
delegate | The object which will handle the incoming stream. A weak reference is maintained to this object by the returned stream. |
NSInvalidArgumentException | Raised if the delegate argument is `nil`. |
|
readnonatomicassign |
A request that can be used to send this value using messaging.
|
readnonatomicassign |
A response that can be used to send this value using messaging.
|
readnonatomicassign |
An update constraint requiring the current value of a topic to match this value.
Use noValue (PTDiffusionUpdateConstraint) to check if the topic has no value.
This constraint is unsatisfied if no topic is present at the path.