functions to pack JSON objects More...
Go to the source code of this file.
Functions | |
json_t * | GNUNET_JSON_pack_ (struct GNUNET_JSON_PackSpec spec[]) |
Pack a JSON object from a spec. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_end_ (void) |
Do not use directly. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_allow_null (struct GNUNET_JSON_PackSpec in) |
Modify packer instruction to allow NULL as a value. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_bool (const char *name, bool b) |
Generate packer instruction for a JSON field of type bool. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_string (const char *name, const char *s) |
Generate packer instruction for a JSON field of type string. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_uint64 (const char *name, uint64_t num) |
Generate packer instruction for a JSON field of type unsigned integer. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_int64 (const char *name, int64_t num) |
Generate packer instruction for a JSON field of type signed integer. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_object_steal (const char *name, json_t *o) |
Generate packer instruction for a JSON field of type JSON object where the reference is taken over by the packer. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_object_incref (const char *name, json_t *o) |
Generate packer instruction for a JSON field of type JSON object where the reference counter is incremented by the packer. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_array_steal (const char *name, json_t *a) |
Generate packer instruction for a JSON field of type JSON array where the reference is taken over by the packer. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_array_incref (const char *name, json_t *a) |
Generate packer instruction for a JSON field of type JSON array where the reference counter is incremented by the packer. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_data_varsize (const char *name, const void *blob, size_t blob_size) |
Generate packer instruction for a JSON field of type variable size binary blob. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_data64_varsize (const char *name, const void *blob, size_t blob_size) |
Generate packer instruction for a JSON field of type variable size binary blob. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_timestamp (const char *name, struct GNUNET_TIME_Timestamp t) |
Generate packer instruction for a JSON field of type timestamp. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_timestamp_nbo (const char *name, struct GNUNET_TIME_TimestampNBO at) |
Generate packer instruction for a JSON field of type timestamp in network byte order. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_time_rel (const char *name, struct GNUNET_TIME_Relative rt) |
Generate packer instruction for a JSON field of type relative time. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_time_rel_nbo (const char *name, struct GNUNET_TIME_RelativeNBO rt) |
Generate packer instruction for a JSON field of type relative time in network byte order. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_rsa_public_key (const char *name, const struct GNUNET_CRYPTO_RsaPublicKey *pk) |
Generate packer instruction for a JSON field of type RSA public key. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_rsa_signature (const char *name, const struct GNUNET_CRYPTO_RsaSignature *sig) |
Generate packer instruction for a JSON field of type RSA signature. More... | |
functions to pack JSON objects
Definition in file json_pack.c.
json_t* GNUNET_JSON_pack_ | ( | struct GNUNET_JSON_PackSpec | spec[] | ) |
Pack a JSON object from a spec.
Aborts if packing fails.
spec | specification object |
Definition at line 30 of file json_pack.c.
References GNUNET_JSON_PackSpec::field_name, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_JSON_PackSpec::object, and ret.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_end_ | ( | void | ) |
Do not use directly.
Use GNUNET_JSON_PACK.
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_allow_null | ( | struct GNUNET_JSON_PackSpec | in | ) |
Modify packer instruction to allow NULL as a value.
in | json pack specification to modify |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_bool | ( | const char * | name, |
bool | b | ||
) |
Generate packer instruction for a JSON field of type bool.
name | name of the field to add to the object |
b | boolean value |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_string | ( | const char * | name, |
const char * | s | ||
) |
Generate packer instruction for a JSON field of type string.
name | name of the field to add to the object |
s | string value |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_uint64 | ( | const char * | name, |
uint64_t | num | ||
) |
Generate packer instruction for a JSON field of type unsigned integer.
Note that the maximum allowed value is still limited by JSON and not UINT64_MAX.
name | name of the field to add to the object |
num | numeric value |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_int64 | ( | const char * | name, |
int64_t | num | ||
) |
Generate packer instruction for a JSON field of type signed integer.
name | name of the field to add to the object |
num | numeric value |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_object_steal | ( | const char * | name, |
json_t * | o | ||
) |
Generate packer instruction for a JSON field of type JSON object where the reference is taken over by the packer.
name | name of the field to add to the object |
o | object to steal |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_object_incref | ( | const char * | name, |
json_t * | o | ||
) |
Generate packer instruction for a JSON field of type JSON object where the reference counter is incremented by the packer.
Note that a deep copy is not performed.
name | name of the field to add to the object |
o | object to increment reference counter of |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_array_steal | ( | const char * | name, |
json_t * | a | ||
) |
Generate packer instruction for a JSON field of type JSON array where the reference is taken over by the packer.
name | name of the field to add to the object |
a | array to steal |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_array_incref | ( | const char * | name, |
json_t * | a | ||
) |
Generate packer instruction for a JSON field of type JSON array where the reference counter is incremented by the packer.
Note that a deep copy is not performed.
name | name of the field to add to the object |
a | array to increment reference counter of |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_data_varsize | ( | const char * | name, |
const void * | blob, | ||
size_t | blob_size | ||
) |
Generate packer instruction for a JSON field of type variable size binary blob.
name | name of the field to add to the object |
blob | binary data to pack |
blob_size | number of bytes in blob |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_data64_varsize | ( | const char * | name, |
const void * | blob, | ||
size_t | blob_size | ||
) |
Generate packer instruction for a JSON field of type variable size binary blob.
Use base64-encoding, instead of the more common Crockford base32-encoding.
name | name of the field to add to the object |
blob | binary data to pack |
blob_size | number of bytes in blob |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_timestamp | ( | const char * | name, |
struct GNUNET_TIME_Timestamp | at | ||
) |
Generate packer instruction for a JSON field of type timestamp.
name | name of the field to add to the object |
at | timestamp pack, a value of 0 is only allowed with GNUNET_JSON_pack_allow_null()! |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_timestamp_nbo | ( | const char * | name, |
struct GNUNET_TIME_TimestampNBO | at | ||
) |
Generate packer instruction for a JSON field of type timestamp in network byte order.
name | name of the field to add to the object |
at | timestamp to pack, a value of 0 is only allowed with GNUNET_JSON_pack_allow_null()! |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_time_rel | ( | const char * | name, |
struct GNUNET_TIME_Relative | rt | ||
) |
Generate packer instruction for a JSON field of type relative time.
name | name of the field to add to the object |
rt | relative time to pack |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_time_rel_nbo | ( | const char * | name, |
struct GNUNET_TIME_RelativeNBO | rt | ||
) |
Generate packer instruction for a JSON field of type relative time in network byte order.
name | name of the field to add to the object |
rt | relative time to pack |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_rsa_public_key | ( | const char * | name, |
const struct GNUNET_CRYPTO_RsaPublicKey * | pk | ||
) |
Generate packer instruction for a JSON field of type RSA public key.
name | name of the field to add to the object |
pk | RSA public key |
Definition at line 30 of file json_pack.c.
struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_rsa_signature | ( | const char * | name, |
const struct GNUNET_CRYPTO_RsaSignature * | sig | ||
) |
Generate packer instruction for a JSON field of type RSA signature.
name | name of the field to add to the object |
sig | RSA signature |
Definition at line 30 of file json_pack.c.