|
static ssize_t | attr_name_with_prefix (fr_sbuff_t *out, fr_dict_attr_t const *da, fr_json_format_t const *format) |
| Get attribute name with optional prefix. More...
|
|
char * | fr_json_afrom_pair_list (TALLOC_CTX *ctx, fr_pair_list_t *vps, fr_json_format_t const *format) |
| Returns a JSON string of a list of value pairs. More...
|
|
bool | fr_json_format_verify (fr_json_format_t const *format, bool verbose) |
| Verify that the options in fr_json_format_t are valid. More...
|
|
int | fr_json_object_to_value_box (TALLOC_CTX *ctx, fr_value_box_t *out, json_object *object, fr_dict_attr_t const *enumv, bool tainted) |
| Convert json object to fr_value_box_t. More...
|
|
fr_slen_t | fr_json_str_from_value (fr_sbuff_t *out, fr_value_box_t *vb, bool include_quotes) |
| Print a value box as its equivalent JSON format without going via a struct json_object (in most cases) More...
|
|
void | fr_json_version_print (void) |
| Print JSON-C version. More...
|
|
static int | json_afrom_value_box (TALLOC_CTX *ctx, json_object **out, fr_pair_t *vp, fr_json_format_t const *format) |
| Convert fr_pair_t into a JSON object. More...
|
|
static struct json_object * | json_array_afrom_pair_list (TALLOC_CTX *ctx, fr_pair_list_t *vps, fr_json_format_t const *format) |
| Returns a JSON array representation of a list of value pairs. More...
|
|
static struct json_object * | json_attr_array_afrom_pair_list (TALLOC_CTX *ctx, fr_pair_list_t *vps, fr_json_format_t const *format) |
| Returns a JSON array of a list of value pairs. More...
|
|
static json_object * | json_object_afrom_pair_list (TALLOC_CTX *ctx, fr_pair_list_t *vps, fr_json_format_t const *format) |
| Returns a JSON object representation of a list of value pairs. More...
|
|
json_object * | json_object_from_value_box (fr_value_box_t const *data) |
| Convert boxed value_box to a JSON object. More...
|
|
static void | json_object_put_assert (json_object *obj) |
|
static json_object * | json_smplobj_afrom_pair_list (TALLOC_CTX *ctx, fr_pair_list_t *vps, fr_json_format_t const *format) |
| Returns a JSON object representation of a list of value pairs. More...
|
|
static struct json_object * | json_value_array_afrom_pair_list (TALLOC_CTX *ctx, fr_pair_list_t *vps, fr_json_format_t const *format) |
| Returns a JSON array of a list of value pairs. More...
|
|
Common functions for working with json-c.
- Id
- e90ea072c88da82d354740724ec29a9a8b1c7a5b
- Author
- Arran Cudbard-Bell
-
Matthew Newton
- Copyright
- 2015 Arran Cudbard-Bell (a.cud.nosp@m.bard.nosp@m.b@fre.nosp@m.erad.nosp@m.ius.o.nosp@m.rg)
-
2015,2020 Network RADIUS SAS (legal.nosp@m.@net.nosp@m.workr.nosp@m.adiu.nosp@m.s.com)
-
2015 The FreeRADIUS Server Project
Definition in file json.c.
Returns a JSON string of a list of value pairs.
The result is a talloc-ed string, freeing the string is the responsibility of the caller.
The 'format' struct contains settings to configure the output JSON document format.
- See also
- fr_json_format_s
Default output, when format is NULL, is:
{
"<attribute0>":{
"type":"<type0>",
"value":[<value0>,<value1>,<valueN>]
},
"<attribute1>":{
"type":"<type1>",
"value":[...]
},
"<attributeN>":{
"type":"<typeN>",
"value":[...]
}
}
- Parameters
-
[in] | ctx | Talloc context. |
[in] | vps | a list of value pairs. |
[in] | format | Formatting control, can be NULL to use default format. |
- Returns
- JSON string representation of the value pairs
Definition at line 1239 of file json.c.
Convert fr_pair_t into a JSON object.
If format.value.enum_as_int is set, and the given VP is an enum value, the integer value is returned as a json_object rather than the text representation.
If format.value.always_string is set then a numeric value pair will be returned as a JSON string object.
- Parameters
-
[in] | ctx | Talloc context. |
[out] | out | returned json object. |
[in] | vp | to get the value of. |
[in] | format | format definition, or NULL. |
- Returns
- 1 if 'out' is the integer enum value, 0 otherwise
- -1 on error.
Definition at line 486 of file json.c.
Returns a JSON array representation of a list of value pairs.
The result is a struct json_object, which should be free'd with json_object_put() by the caller. Intended to only be called by fr_json_afrom_pair_list().
This function generates the "array" format, JSON_MODE_ARRAY.
- See also
- fr_json_format_s
- Parameters
-
[in] | ctx | Talloc context. |
[in] | vps | a list of value pairs. |
[in] | format | Formatting control, must be set. |
- Returns
- JSON object with the generated representation.
Definition at line 950 of file json.c.
Returns a JSON array of a list of value pairs.
The result is a struct json_object, which should be free'd with json_object_put() by the caller. Intended to only be called by fr_json_afrom_pair_list().
This function generates the "array_of_names" format, JSON_MODE_ARRAY_OF_NAMES, listing just the attribute names.
- See also
- fr_json_format_s
- Parameters
-
[in] | ctx | Talloc context. |
[in] | vps | a list of value pairs. |
[in] | format | Formatting control, must be set. |
- Returns
- JSON object with the generated representation.
Definition at line 1157 of file json.c.
Returns a JSON object representation of a list of value pairs.
The result is a struct json_object, which should be free'd with json_object_put() by the caller. Intended to only be called by fr_json_afrom_pair_list().
This function generates the "object" format, JSON_MODE_OBJECT.
- See also
- fr_json_format_s
{
"<attribute0>":{
"type":"<type0>",
"value":[<value0>,<value1>,<valueN>] // if value_is_always_array is true
}, // or
"<attribute1>":{
"type":"<type1>",
"value":<value0> // if value_is_always_array is false
// and there is only one value
},
"<attributeN>":{
"type":"<typeN>",
"value":[...]
}
}
- Parameters
-
[in] | ctx | Talloc context. |
[in] | vps | a list of value pairs. |
[in] | format | Formatting control, must be set. |
- Returns
- JSON object with the generated representation.
Definition at line 644 of file json.c.
Returns a JSON object representation of a list of value pairs.
The result is a struct json_object, which should be free'd with json_object_put() by the caller. Intended to only be called by fr_json_afrom_pair_list().
This function generates the "simple object" format, JSON_MODE_OBJECT_SIMPLE.
- See also
- fr_json_format_s
{
"<attribute0>":[<value0>,<value1>,<valueN>] // if value_is_always_array is true
// or
"<attribute1>":<value0> // if value_is_always_array is false,
// and there is only one value
"<attributeN>":[<value0>,<value1>,<valueN>]
}
- Parameters
-
[in] | ctx | Talloc context. |
[in] | vps | a list of value pairs. |
[in] | format | Formatting control, must be set. |
- Returns
- JSON object with the generated representation.
Definition at line 811 of file json.c.
Returns a JSON array of a list of value pairs.
The result is a struct json_object, which should be free'd with json_object_put() by the caller. Intended to only be called by fr_json_afrom_pair_list().
This function generates the "array_of_values" format, JSON_MODE_ARRAY_OF_VALUES, listing just the attribute values.
- See also
- fr_json_format_s
- Parameters
-
[in] | ctx | Talloc context. |
[in] | vps | a list of value pairs. |
[in] | format | Formatting control, must be set. |
- Returns
- JSON object with the generated representation.
Definition at line 1095 of file json.c.