Skip to content

Commit

Permalink
lib/json: CONF_PARSER definition for json_format
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnewton committed Feb 21, 2020
1 parent 08356b5 commit 10ebda5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/json/base.h
Expand Up @@ -226,6 +226,8 @@ struct fr_json_format_s {

typedef struct fr_json_format_s fr_json_format_t;

extern CONF_PARSER const fr_json_format_config[];


/* jpath .c */
typedef struct fr_jpath_node fr_jpath_node_t;
Expand Down
22 changes: 22 additions & 0 deletions src/lib/json/json.c
Expand Up @@ -43,6 +43,28 @@ static fr_json_format_t const default_json_format = {
.value = { .value_as_array = true },
};

CONF_PARSER const json_format_attr_config[] = {
{ FR_CONF_OFFSET("prefix", FR_TYPE_STRING, fr_json_format_attr_t, prefix) },
CONF_PARSER_TERMINATOR
};

CONF_PARSER const json_format_value_config[] = {
{ FR_CONF_OFFSET("single_value_as_array", FR_TYPE_BOOL, fr_json_format_value_t, value_as_array), .dflt = "no" },
{ FR_CONF_OFFSET("enum_as_integer", FR_TYPE_BOOL, fr_json_format_value_t, enum_as_int), .dflt = "no" },
{ FR_CONF_OFFSET("always_string", FR_TYPE_BOOL, fr_json_format_value_t, always_string), .dflt = "no" },
CONF_PARSER_TERMINATOR
};

CONF_PARSER const fr_json_format_config[] = {
{ FR_CONF_OFFSET("output_mode", FR_TYPE_STRING, fr_json_format_t, output_mode_str), .dflt = "object" },
{ FR_CONF_OFFSET("attribute", FR_TYPE_SUBSECTION, fr_json_format_t, attr),
.subcs = (void const *) json_format_attr_config },
{ FR_CONF_OFFSET("value", FR_TYPE_SUBSECTION, fr_json_format_t, value),
.subcs = (void const *) json_format_value_config },

CONF_PARSER_TERMINATOR
};


/** Convert json object to fr_value_box_t
*
Expand Down

0 comments on commit 10ebda5

Please sign in to comment.