|
Objectively
Ultra-lightweight object oriented framework for GNU C.
|
#include <stdint.h>#include <stdlib.h>#include <string.h>#include "Boole.h"#include "Date.h"#include "DateFormatter.h"#include "JSONContext.h"#include "Array.h"#include "Dictionary.h"#include "Set.h"#include "Null.h"#include "Number.h"#include "URL.h"Go to the source code of this file.
Functions | |
| bool | JSONDeserializeArray (const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context) |
| Deserializes a JSON array into an inline array field. | |
| bool | JSONDeserializeBoole (const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context) |
Deserializes a JSON boolean into a bool field. | |
| 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. | |
| 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. | |
| 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). | |
| bool | JSONDeserializeDictionary (const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context) |
Deserializes a JSON object into a Dictionary * field. | |
| bool | JSONDeserializeDouble (const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context) |
Deserializes a JSON number into a double field. | |
| bool | JSONDeserializeFloat (const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context) |
Deserializes a JSON number into a float field. | |
| bool | JSONDeserializeInt32 (const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context) |
Deserializes a JSON number into an int32_t field. | |
| bool | JSONDeserializeInt64 (const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context) |
Deserializes a JSON number into an int64_t field. | |
| bool | JSONDeserializeObjectArray (const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context) |
Deserializes a JSON array into an Array * field. | |
| bool | JSONDeserializeSet (const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context) |
Deserializes a JSON array into a Set * field. | |
| bool | JSONDeserializeString (const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context) |
Deserializes a JSON string into a String * field. | |
| bool | JSONDeserializeStruct (const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context) |
| Deserializes a JSON object into a nested struct field. | |
| bool | JSONDeserializeUint32 (const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context) |
Deserializes a JSON number into a uint32_t field. | |
| bool | JSONDeserializeUint64 (const JSONProperties *properties, const JSONProperty *property, const Object *value, ident field, JSONContext *context) |
Deserializes a JSON number into a uint64_t field. | |
| 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. | |
| ident | JSONSerializeArray (const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context) |
| Serializes an inline array field to a JSON array. | |
| ident | JSONSerializeBoole (const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context) |
Serializes a bool field to a JSON boolean. | |
| ident | JSONSerializeCharacters (const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context) |
Serializes a fixed-size char[] field to a JSON string. | |
| 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 | 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). | |
| ident | JSONSerializeDictionary (const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context) |
Serializes a Dictionary * field to a JSON object. | |
| ident | JSONSerializeDouble (const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context) |
Serializes a double field to a JSON number. | |
| ident | JSONSerializeFloat (const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context) |
Serializes a float field to a JSON number. | |
| ident | JSONSerializeInt32 (const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context) |
Serializes an int32_t field to a JSON number. | |
| ident | JSONSerializeInt64 (const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context) |
Serializes an int64_t field to a JSON number. | |
| ident | JSONSerializeObjectArray (const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context) |
Serializes an Array * field to a JSON array. | |
| ident | JSONSerializeSet (const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context) |
Serializes a Set * field to a JSON array. | |
| ident | JSONSerializeString (const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context) |
Serializes a String * field to a JSON string. | |
| ident | JSONSerializeStruct (const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context) |
| Serializes a nested struct field to a JSON object. | |
| ident | JSONSerializeUint32 (const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context) |
Serializes a uint32_t field to a JSON number. | |
| ident | JSONSerializeUint64 (const JSONProperties *properties, const JSONProperty *property, ident value, ident data, JSONContext *context) |
Serializes a uint64_t field to a JSON number. | |
| 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). | |
| bool JSONDeserializeArray | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| const Object * | value, | ||
| ident | field, | ||
| JSONContext * | context | ||
| ) |
Deserializes a JSON array into an inline array field.
property->data must point to a JSONArrayProperties.
false if the JSON value is not an Array. Definition at line 501 of file JSONSerializers.c.
| bool JSONDeserializeBoole | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| const Object * | value, | ||
| ident | field, | ||
| JSONContext * | context | ||
| ) |
Deserializes a JSON boolean into a bool field.
false if the JSON value is not a Boole. Definition at line 454 of file JSONSerializers.c.
| 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.
property->data must carry the field size via JSONFieldSize.
false if the JSON value is not a String. Definition at line 251 of file JSONSerializers.c.
| 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.
The existing pointer is freed before replacement.
false if the JSON value is not a String. Definition at line 278 of file JSONSerializers.c.
| 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).
Pass a const char * format string as property->data to override the format.
false if the JSON value is not a String or cannot be parsed. Definition at line 632 of file JSONSerializers.c.
| bool JSONDeserializeDictionary | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| const Object * | value, | ||
| ident | field, | ||
| JSONContext * | context | ||
| ) |
Deserializes a JSON object into a Dictionary * field.
The existing Dictionary is released before replacement.
false if the JSON value is not a Dictionary. Definition at line 753 of file JSONSerializers.c.
| bool JSONDeserializeDouble | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| const Object * | value, | ||
| ident | field, | ||
| JSONContext * | context | ||
| ) |
Deserializes a JSON number into a double field.
false if the JSON value is not a Number. Definition at line 429 of file JSONSerializers.c.
| bool JSONDeserializeFloat | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| const Object * | value, | ||
| ident | field, | ||
| JSONContext * | context | ||
| ) |
Deserializes a JSON number into a float field.
false if the JSON value is not a Number. Definition at line 404 of file JSONSerializers.c.
| bool JSONDeserializeInt32 | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| const Object * | value, | ||
| ident | field, | ||
| JSONContext * | context | ||
| ) |
Deserializes a JSON number into an int32_t field.
false if the JSON value is not a Number. Definition at line 304 of file JSONSerializers.c.
| bool JSONDeserializeInt64 | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| const Object * | value, | ||
| ident | field, | ||
| JSONContext * | context | ||
| ) |
Deserializes a JSON number into an int64_t field.
JSON numbers are IEEE 754 doubles (53-bit mantissa). Values beyond 2^53 will lose precision on round-trip.
false if the JSON value is not a Number. Definition at line 354 of file JSONSerializers.c.
| bool JSONDeserializeObjectArray | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| const Object * | value, | ||
| ident | field, | ||
| JSONContext * | context | ||
| ) |
Deserializes a JSON array into an Array * field.
The existing Array is released before replacement. Elements are retained as their parsed Objectively types (String, Number, Boole, etc.).
false if the JSON value is not an Array. Definition at line 671 of file JSONSerializers.c.
| bool JSONDeserializeSet | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| const Object * | value, | ||
| ident | field, | ||
| JSONContext * | context | ||
| ) |
Deserializes a JSON array into a Set * field.
The existing Set is released before replacement.
false if the JSON value is not an Array. Definition at line 714 of file JSONSerializers.c.
| bool JSONDeserializeString | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| const Object * | value, | ||
| ident | field, | ||
| JSONContext * | context | ||
| ) |
Deserializes a JSON string into a String * field.
The existing String is released before replacement.
false if the JSON value is not a String. Definition at line 552 of file JSONSerializers.c.
| bool JSONDeserializeStruct | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| const Object * | value, | ||
| ident | field, | ||
| JSONContext * | context | ||
| ) |
Deserializes a JSON object into a nested struct field.
property->data must point to a JSONProperties describing the nested type.
false if the JSON value is not a Dictionary. Definition at line 479 of file JSONSerializers.c.
| bool JSONDeserializeUint32 | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| const Object * | value, | ||
| ident | field, | ||
| JSONContext * | context | ||
| ) |
Deserializes a JSON number into a uint32_t field.
false if the JSON value is not a Number. Definition at line 329 of file JSONSerializers.c.
| bool JSONDeserializeUint64 | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| const Object * | value, | ||
| ident | field, | ||
| JSONContext * | context | ||
| ) |
Deserializes a JSON number into a uint64_t field.
JSON numbers are IEEE 754 doubles (53-bit mantissa). Values beyond 2^53 will lose precision on round-trip.
false if the JSON value is not a Number. Definition at line 379 of file JSONSerializers.c.
| 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.
The existing URL is released before replacement.
false if the JSON value is not a String. Definition at line 589 of file JSONSerializers.c.
| ident JSONSerializeArray | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |
Serializes an inline array field to a JSON array.
property->data must point to a JSONArrayProperties.
Definition at line 223 of file JSONSerializers.c.
| ident JSONSerializeBoole | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |
Serializes a bool field to a JSON boolean.
Definition at line 188 of file JSONSerializers.c.
| ident JSONSerializeCharacters | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |
Serializes a fixed-size char[] field to a JSON string.
Omits the key (returns NULL) when the field is empty.
Definition at line 42 of file JSONSerializers.c.
| ident JSONSerializeCString | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |
Serializes a char * heap string field to a JSON string.
Omits the key (returns NULL) when the pointer is NULL.
Definition at line 61 of file JSONSerializers.c.
| 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).
Pass a const char * format string as property->data to override the format.
Definition at line 611 of file JSONSerializers.c.
| ident JSONSerializeDictionary | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |
Serializes a Dictionary * field to a JSON object.
Values are written as-is; each must be a JSON-compatible Objectively type.
Definition at line 738 of file JSONSerializers.c.
| ident JSONSerializeDouble | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |
Serializes a double field to a JSON number.
Definition at line 170 of file JSONSerializers.c.
| ident JSONSerializeFloat | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |
Serializes a float field to a JSON number.
Definition at line 152 of file JSONSerializers.c.
| ident JSONSerializeInt32 | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |
Serializes an int32_t field to a JSON number.
Definition at line 80 of file JSONSerializers.c.
| ident JSONSerializeInt64 | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |
Serializes an int64_t field to a JSON number.
JSON numbers are IEEE 754 doubles (53-bit mantissa). Values beyond 2^53 will lose precision on round-trip.
Definition at line 116 of file JSONSerializers.c.
| ident JSONSerializeObjectArray | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |
Serializes an Array * field to a JSON array.
Elements are written as-is; each must be a JSON-compatible Objectively type.
Definition at line 656 of file JSONSerializers.c.
| ident JSONSerializeSet | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |
Serializes a Set * field to a JSON array.
Elements are written as-is; each must be a JSON-compatible Objectively type.
Definition at line 695 of file JSONSerializers.c.
| ident JSONSerializeString | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |
| ident JSONSerializeStruct | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |
Serializes a nested struct field to a JSON object.
property->data must point to a JSONProperties describing the nested type.
Definition at line 206 of file JSONSerializers.c.
| ident JSONSerializeUint32 | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |
Serializes a uint32_t field to a JSON number.
Definition at line 98 of file JSONSerializers.c.
| ident JSONSerializeUint64 | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |
Serializes a uint64_t field to a JSON number.
JSON numbers are IEEE 754 doubles (53-bit mantissa). Values beyond 2^53 will lose precision on round-trip.
Definition at line 134 of file JSONSerializers.c.
| ident JSONSerializeURL | ( | const JSONProperties * | properties, |
| const JSONProperty * | property, | ||
| ident | value, | ||
| ident | data, | ||
| JSONContext * | context | ||
| ) |