|
Objectively
Ultra-lightweight object oriented framework for GNU C.
|
#include <JSONContext.h>
A context for JSON serialization and deserialization.
Create one instance per operation. Errors encountered during parsing or type-binding accumulate in errors.
Definition at line 72 of file JSONContext.h.
Properties | |
| Array * | errors |
| Errors accumulated during the operation. | |
| Object | object |
| The superclass. | |
Properties inherited from Object | |
| Class * | clazz |
| Every instance of Object begins with a pointer to its Class. | |
| unsigned int | magic |
| A header to allow introspection of Object types. | |
Methods | |
| Class * | _JSONContext (void) |
| The JSONContext archetype. | |
| Data * | dataFromObject (JSONContext *self, const ident obj, int options) |
| Serializes an Objectively object graph to JSON Data. | |
| Data * | dataFromStruct (JSONContext *self, const JSONProperties *properties, const ident instance) |
| Serializes a C struct instance to a JSON object. | |
| Data * | dataFromStructs (JSONContext *self, const JSONProperties *properties, const ident instances, size_t count) |
| Serializes an array of C struct instances to a JSON array. | |
| Dictionary * | dictionaryFromStruct (JSONContext *self, const JSONProperties *properties, const ident instance) |
| Serializes a C struct instance to a Dictionary. | |
| JSONContext * | init (JSONContext *self) |
| Initializes a JSONContext. | |
| ident | objectFromData (JSONContext *self, const Data *data, int options) |
| Parses a JSON Data buffer into an Objectively object graph. | |
| bool | structFromData (JSONContext *self, const JSONProperties *properties, const Data *data, ident instance) |
| Deserializes a top-level JSON object into a C struct. | |
| bool | structFromDictionary (JSONContext *self, const JSONProperties *properties, const Dictionary *dictionary, ident instance) |
| Deserializes a Dictionary into a C struct. | |
| size_t | structsFromArray (JSONContext *self, const JSONProperties *properties, const Array *array, ident instances, size_t count) |
| Deserializes an Array of Dictionaries into an array of C structs. | |
| size_t | structsFromData (JSONContext *self, const JSONProperties *properties, const Data *data, ident instances, size_t count) |
| Deserializes a top-level JSON array into an array of C structs. | |
Methods inherited from Object | |
| Class * | _Object (void) |
| The Object archetype. | |
| Object * | copy (const Object *self) |
| Creates a shallow copy of this Object. | |
| void | dealloc (Object *self) |
| Frees all resources held by this Object. | |
| String * | description (const Object *self) |
| int | hash (const Object *self) |
| Object * | init (Object *self) |
| Initializes this Object. | |
| bool | isEqual (const Object *self, const Object *other) |
| Tests equality of the other Object. | |
| bool | isKindOfClass (const Object *self, const Class *clazz) |
| Tests for Class hierarchy membership. | |
Protected Attributes | |
| JSONContextInterface * | interface |
| The interface. | |
Protected Attributes inherited from Object | |
| ObjectInterface * | interface |
| The interface. | |
| Array* JSONContext::errors |
Errors accumulated during the operation.
Lazily allocated; NULL until the first error is recorded.
Definition at line 89 of file JSONContext.h.
|
protected |
The interface.
Definition at line 83 of file JSONContext.h.
| Object JSONContext::object |
The superclass.
Definition at line 77 of file JSONContext.h.
| Class * _JSONContext | ( | void | ) |
The JSONContext archetype.
Definition at line 821 of file JSONContext.c.
| Data * dataFromObject | ( | JSONContext * | self, |
| const ident | obj, | ||
| int | options | ||
| ) |
Serializes an Objectively object graph to JSON Data.
| self | The JSONContext. |
| obj | The root Object to serialize. |
| options | A bitwise-or of JSONWriteOptions. |
Definition at line 584 of file JSONContext.c.
| Data * dataFromStruct | ( | JSONContext * | self, |
| const JSONProperties * | properties, | ||
| const ident | instance | ||
| ) |
Serializes a C struct instance to a JSON object.
| self | The JSONContext. |
| properties | The JSONProperties for the struct type. |
| instance | Pointer to the struct instance. |
Definition at line 606 of file JSONContext.c.
| Data * dataFromStructs | ( | JSONContext * | self, |
| const JSONProperties * | properties, | ||
| const ident | instances, | ||
| size_t | count | ||
| ) |
Serializes an array of C struct instances to a JSON array.
| self | The JSONContext. |
| properties | The JSONProperties for the struct type. |
| instances | Pointer to the first instance. |
| count | The number of instances to serialize. |
NULL if count is zero. Definition at line 618 of file JSONContext.c.
| Dictionary * dictionaryFromStruct | ( | JSONContext * | self, |
| const JSONProperties * | properties, | ||
| const ident | instance | ||
| ) |
Serializes a C struct instance to a Dictionary.
| self | The JSONContext. |
| properties | The JSONProperties for the struct type. |
| instance | Pointer to the struct instance. |
NULL on error. Definition at line 641 of file JSONContext.c.
| JSONContext * init | ( | JSONContext * | self | ) |
Initializes a JSONContext.
| self | The JSONContext. |
Definition at line 671 of file JSONContext.c.
| ident objectFromData | ( | JSONContext * | self, |
| const Data * | data, | ||
| int | options | ||
| ) |
Parses a JSON Data buffer into an Objectively object graph.
| self | The JSONContext. |
| data | The JSON Data to parse. |
| options | Reserved; pass 0. |
NULL on parse error. Definition at line 679 of file JSONContext.c.
| bool structFromData | ( | JSONContext * | self, |
| const JSONProperties * | properties, | ||
| const Data * | data, | ||
| ident | instance | ||
| ) |
Deserializes a top-level JSON object into a C struct.
| self | The JSONContext. |
| properties | The JSONProperties for the struct type. |
| data | The JSON Data containing a top-level object. |
| instance | Pointer to the caller-allocated struct to populate. |
true if parsing succeeded and all recognized fields were bound without type errors. Definition at line 757 of file JSONContext.c.
| bool structFromDictionary | ( | JSONContext * | self, |
| const JSONProperties * | properties, | ||
| const Dictionary * | dictionary, | ||
| ident | instance | ||
| ) |
Deserializes a Dictionary into a C struct.
| self | The JSONContext. |
| properties | The JSONProperties for the struct type. |
| dictionary | The source Dictionary. |
| instance | Pointer to the caller-allocated struct to populate. |
true if all recognized fields were bound without type errors. Definition at line 704 of file JSONContext.c.
| size_t structsFromArray | ( | JSONContext * | self, |
| const JSONProperties * | properties, | ||
| const Array * | array, | ||
| ident | instances, | ||
| size_t | count | ||
| ) |
Deserializes an Array of Dictionaries into an array of C structs.
| self | The JSONContext. |
| properties | The JSONProperties for the element type. |
| array | The source Array of Dictionary objects. |
| instances | Pointer to a caller-allocated buffer of at least count structs. |
| count | The capacity of the instances buffer. |
Definition at line 737 of file JSONContext.c.
| size_t structsFromData | ( | JSONContext * | self, |
| const JSONProperties * | properties, | ||
| const Data * | data, | ||
| ident | instances, | ||
| size_t | count | ||
| ) |
Deserializes a top-level JSON array into an array of C structs.
| self | The JSONContext. |
| properties | The JSONProperties for the element type. |
| data | The JSON Data containing a top-level array. |
| instances | Pointer to a caller-allocated buffer of at least count structs. |
| count | The capacity of the instances buffer. |
Definition at line 775 of file JSONContext.c.