142#define MakeJSONProperty(Struct, field, serializer_, deserializer_, data_) \
145 .offset = (ptrdiff_t) offsetof(Struct, field), \
146 .size = sizeof(((Struct *) NULL)->field), \
147 .serializer = (serializer_), \
148 .deserializer = (deserializer_), \
155#define MakeJSONProperties(Struct, ...) \
158 .size = sizeof(Struct), \
159 .properties = (const JSONProperty[]) { \
161 (JSONProperty) { .key = NULL } \
165#pragma mark - Standard JSONSerializers
274#pragma mark - Standard JSONDeserializers
394#pragma mark - JSONArrayProperties
399#define JSONArrayProperties_NoCount ((ptrdiff_t) -1)
431#define MakeJSONArrayProperties(properties, capacity, count) \
432 &(JSONArrayProperties){ .properties = (properties), .capacity = (capacity), .count = (count) }
434# pragma mark - Object serializers
Microsecond-precision immutable dates.
OBJECTIVELY_EXPORT bool JSONDeserializeCString(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON string into a heap-allocated char * field.
OBJECTIVELY_EXPORT bool JSONDeserializeURL(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON string into a URL * field via initWithString.
OBJECTIVELY_EXPORT ident JSONSerializeUint32(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes a uint32_t field to a JSON number.
OBJECTIVELY_EXPORT bool JSONDeserializeDate(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON string into a Date * field (ISO 8601 by default).
OBJECTIVELY_EXPORT ident JSONSerializeDouble(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes a double field to a JSON number.
OBJECTIVELY_EXPORT bool JSONDeserializeCharacters(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON string into a fixed-size char[] field.
OBJECTIVELY_EXPORT ident JSONSerializeString(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes a String * field to a JSON string.
OBJECTIVELY_EXPORT ident JSONSerializeURL(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes a URL * field to a JSON string (the URL's string form).
OBJECTIVELY_EXPORT bool JSONDeserializeFloat(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON number into a float field.
OBJECTIVELY_EXPORT ident JSONSerializeDate(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes a Date * field to a JSON string (ISO 8601 by default).
OBJECTIVELY_EXPORT ident JSONSerializeCharacters(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes a fixed-size char[] field to a JSON string.
OBJECTIVELY_EXPORT ident JSONSerializeUint64(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes a uint64_t field to a JSON number.
OBJECTIVELY_EXPORT bool JSONDeserializeInt32(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON number into an int32_t field.
OBJECTIVELY_EXPORT bool JSONDeserializeUint64(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON number into a uint64_t field.
OBJECTIVELY_EXPORT ident JSONSerializeBoole(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes a bool field to a JSON boolean.
bool(* JSONDeserializer)(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON value into a C struct field.
OBJECTIVELY_EXPORT bool JSONDeserializeString(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON string into a String * field.
OBJECTIVELY_EXPORT ident JSONSerializeCString(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes a char * heap string field to a JSON string.
ident(* JSONSerializer)(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes a C struct field to an Objectively Object.
OBJECTIVELY_EXPORT ident JSONSerializeDictionary(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes a Dictionary * field to a JSON object.
OBJECTIVELY_EXPORT ident JSONSerializeInt64(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes an int64_t field to a JSON number.
OBJECTIVELY_EXPORT ident JSONSerializeSet(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes a Set * field to a JSON array.
OBJECTIVELY_EXPORT bool JSONDeserializeObjectArray(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON array into an Array * field.
OBJECTIVELY_EXPORT bool JSONDeserializeArray(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON array into an inline array field.
OBJECTIVELY_EXPORT ident JSONSerializeStruct(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes a nested struct field to a JSON object.
OBJECTIVELY_EXPORT ident JSONSerializeFloat(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes a float field to a JSON number.
OBJECTIVELY_EXPORT bool JSONDeserializeDictionary(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON object into a Dictionary * field.
OBJECTIVELY_EXPORT bool JSONDeserializeDouble(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON number into a double field.
OBJECTIVELY_EXPORT ident JSONSerializeInt32(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes an int32_t field to a JSON number.
OBJECTIVELY_EXPORT bool JSONDeserializeSet(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON array into a Set * field.
OBJECTIVELY_EXPORT bool JSONDeserializeUint32(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON number into a uint32_t field.
OBJECTIVELY_EXPORT bool JSONDeserializeInt64(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON number into an int64_t field.
OBJECTIVELY_EXPORT bool JSONDeserializeBoole(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON boolean into a bool field.
OBJECTIVELY_EXPORT ident JSONSerializeArray(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes an inline array field to a JSON array.
OBJECTIVELY_EXPORT bool JSONDeserializeStruct(const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context)
Deserializes a JSON object into a nested struct field.
OBJECTIVELY_EXPORT ident JSONSerializeObjectArray(const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context)
Serializes an Array * field to a JSON array.
Object is the root Class of The Objectively Class hierarchy.
void * ident
The identity type, similar to Objective-C id.
#define OBJECTIVELY_EXPORT
Uniform Resource Locators (RFC 3986).
Describes the JSON binding for an inline array field of a C struct.
const JSONProperties * properties
The JSONProperties of the array element type.
ptrdiff_t count
Byte offset of the sibling element-count field, or JSONArrayProperties_NoCount.
size_t capacity
The capacity of the array field (maximum number of elements).
A context for JSON serialization and deserialization.
Describes the JSON binding for all fields of a C struct.
const JSONProperty * properties
The NULL-terminated JSONProperty array.
size_t size
The struct size, i.e. sizeof(Struct).
const char * name
The struct type name.
Describes the JSON binding strategy for a single field of a C struct.
JSONSerializer serializer
The JSONSerializer, or NULL to omit this field from serialization.
ptrdiff_t offset
The byte offset of the field within the struct.
ident data
Opaque user data passed to the serializer and deserializer.
const char * key
The JSON key name. A NULL key terminates the property list.
size_t size
The byte size of the field within the struct.
JSONDeserializer deserializer
The JSONDeserializer, or NULL to omit this field from deserialization.
Object is the root Class of The Objectively Class hierarchy.