PSPDFJSONSerializing

@protocol PSPDFJSONSerializing

A PSPDFModel object that supports being parsed from and serialized to JSON.

  • Returns a dictionary mapping property keys to JSON key paths (as strings) or NSNull values.

    Declaration

    Objective-C

    + (nonnull NSDictionary<NSString *, id> *)JSONKeyPathsByPropertyKey;

    Swift

    static func jsonKeyPathsByPropertyKey() -> [String : Any]
  • Specifies how to convert a JSON value to the given property key. If reversible, the transformer will also be used to convert the property value back to JSON.

    If the receiver implements a +<key>JSONTransformer method, PSPDFJSONAdapter will use the result of that method instead.

    Returns a value transformer, or nil if no transformation should be performed.

    Declaration

    Objective-C

    + (nullable NSValueTransformer *)JSONTransformerForKey:(nonnull NSString *)key;

    Swift

    optional static func jsonTransformer(forKey key: String) -> ValueTransformer?
  • Overridden to parse the receiver as a different class, based on information in the provided dictionary.

    This is mostly useful for class clusters, where the abstract base class would be passed into -[PSPDFJSONAdapter initWithJSONDictionary:modelClass:], but a subclass should be instantiated instead.

    Returns the class that should be parsed (which may be the receiver), or nil to abort parsing (e.g., if the data is invalid).

    Declaration

    Objective-C

    + (nullable Class)classForParsingJSONDictionary:
        (nonnull NSDictionary<NSString *, id> *)JSONDictionary;

    Swift

    optional static func `class`(forParsingJSONDictionary JSONDictionary: [String : Any]) -> AnyClass?

    Parameters

    JSONDictionary

    The JSON dictionary that will be parsed.