yumapro
24.10-1
YumaPro SDK
|
Contains JSON parsing and output utilities. More...
Data Structures | |
struct | json_walker_cookie_t |
JSON walker function for GET2 support. More... | |
Enumerations | |
enum | json_wr_tag_t |
type parser used in 3 separate modes | |
Functions | |
status_t | json_parse_top_identifier (ses_cb_t *scb, xml_msg_hdr_t *msg, obj_template_t *obj, const xmlChar **modname, const xmlChar **name, xmlChar **tempbuff) |
Parse a top-level JSON object;. More... | |
status_t | json_parse_text (ses_cb_t *scb, xml_msg_hdr_t *msg, obj_template_t *obj, dlq_hdr_t *returnQ) |
Parse token chain representing JSON Text. More... | |
status_t | json_parse_buffer (xmlChar *buff, obj_template_t *obj, dlq_hdr_t *returnQ) |
Parse buffer of JSON into val_value_t structs. More... | |
void | json_wr_start_object (ses_cb_t *scb, xml_msg_hdr_t *msg, const xmlChar *modname, const xmlChar *name, int32 startindent) |
generate start of a JSON object More... | |
void | json_wr_start_object_ex (ses_cb_t *scb, xml_msg_hdr_t *msg, const xmlChar *modname, const xmlChar *name, int32 startindent, boolean startbrace, boolean endbrace) |
generate start of a JSON object (extended version) More... | |
void | json_wr_start_object_val (ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 startindent) |
generate start of a JSON object based on val value tree More... | |
void | json_wr_start_object_obj (ses_cb_t *scb, xml_msg_hdr_t *msg, const xmlChar *modname, const xmlChar *name, obj_template_t *obj, int32 startindent) |
generate start of a JSON object based on val value tree; use OBJ to check the modname More... | |
void | json_wr_end_object (ses_cb_t *scb, xml_msg_hdr_t *msg, int32 startindent) |
generate end of a JSON object More... | |
void | json_wr_start_array (ses_cb_t *scb, xml_msg_hdr_t *msg, int32 startindent) |
generate start of a JSON array More... | |
void | json_wr_start_array_obj (ses_cb_t *scb, xml_msg_hdr_t *msg, const xmlChar *modname, const xmlChar *name, obj_template_t *obj, int32 startindent, boolean startbrace, boolean startbracket) |
generate start of a JSON array; use OBJ to check the modname More... | |
void | json_wr_start_array_val (ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 startindent, boolean startbrace, boolean startbracket) |
generate start of a JSON array; use value node More... | |
void | json_wr_end_array (ses_cb_t *scb, xml_msg_hdr_t *msg, int32 startindent) |
generate end of a JSON array More... | |
void | json_wr_simval_line (ses_cb_t *scb, xml_msg_hdr_t *msg, xmlns_id_t nsid, const xmlChar *namestr, const xmlChar *valstr, ncx_btype_t btyp, int32 startindent, boolean isfirst) |
generate 1 line for a simple value within a container or array More... | |
status_t | json_wr_max_check_val (ses_cb_t *scb, xml_msg_hdr_t *msg, xmlns_id_t parent_nsid, val_value_t *val, int32 startindent, val_nodetest_fn_t testfn, boolean isfirst, boolean islast, boolean isfirstchild, boolean isfirstsibling, boolean force_lastsibling, boolean force_lastsib_value, boolean force_array_obj) |
generate entire val_value_t *w/filter) More... | |
status_t | json_wr_max_check_val_force (ses_cb_t *scb, xml_msg_hdr_t *msg, xmlns_id_t parent_nsid, val_value_t *val, int32 startindent, val_nodetest_fn_t testfn, boolean isfirst, boolean islast, boolean isfirstchild, boolean isfirstsibling, boolean force_lastsibling, boolean force_lastsib_value, boolean force_array_obj, xmlns_id_t force_nsid, const xmlChar *force_name) |
generate entire val_value_t *w/filter) More... | |
status_t | json_wr_full_check_val (ses_cb_t *scb, xml_msg_hdr_t *msg, xmlns_id_t parent_nsid, val_value_t *val, int32 startindent, val_nodetest_fn_t testfn) |
generate entire val_value_t *w/filter) More... | |
status_t | json_wr_full_check_val_force (ses_cb_t *scb, xml_msg_hdr_t *msg, xmlns_id_t parent_nsid, val_value_t *val, int32 startindent, val_nodetest_fn_t testfn, xmlns_id_t force_nsid, const xmlChar *force_name) |
generate entire val_value_t *w/filter) More... | |
status_t | json_wr_check_open_file (FILE *fp, val_value_t *val, int32 startindent, int32 indent, val_nodetest_fn_t testfn) |
Write the specified value to an open FILE in JSON format. More... | |
status_t | json_wr_check_open_file2 (FILE *fp, val_value_t *val, int32 startindent, int32 indent, val_nodetest_fn_t testfn, boolean modnames) |
Write the specified value to an open FILE in JSON format Allow JSON or JSON-IETF format. More... | |
status_t | json_wr_check_file (const xmlChar *filespec, val_value_t *val, int32 startindent, int32 indent, val_nodetest_fn_t testfn) |
Write the specified value to a FILE in JSON format. More... | |
status_t | json_wr_check_file2 (const xmlChar *filespec, val_value_t *val, int32 startindent, int32 indent, val_nodetest_fn_t testfn, boolean modnames) |
Write the specified value to a FILE in JSON format. More... | |
status_t | json_wr_file (const xmlChar *filespec, val_value_t *val, int32 startindent, int32 indent) |
Write the specified value to a FILE in JSON format. More... | |
status_t | json_wr_file2 (const xmlChar *filespec, val_value_t *val, int32 startindent, int32 indent, boolean modnames) |
Write the specified value to a FILE in JSON format. More... | |
void | json_wr_output_null (ses_cb_t *scb, int32 startindent) |
generate a null value; needed for printing empty <data> element which is done as a wrapper, not a real value node More... | |
void | json_wr_check_child_obj (ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, obj_template_t *objnode, int32 indent, val_nodetest_fn_t testfn, boolean isfirst, boolean isfirstchild) |
generate entire val_value_t *w/filter) More... | |
void | json_wr_check_child_obj_ex (ses_cb_t *scb, xml_msg_hdr_t *msg, getcb_get2_t *parent_get2cb, obj_template_t *objnode, int32 indent, val_nodetest_fn_t testfn, boolean isfirst, boolean isfirstchild) |
generate entire val_value_t *w/filter) (extended version) More... | |
Contains JSON parsing and output utilities.
JSON output functions.
Used by the client and server for RESTCONF protocol messages. Also used by yangcli-pro display-mode=json.
Generates plain or YANG JSON format.
status_t json_parse_buffer | ( | xmlChar * | buff, |
obj_template_t * | obj, | ||
dlq_hdr_t * | returnQ | ||
) |
Parse buffer of JSON into val_value_t structs.
Defaults are not added to any objects Missing objects are not checked
A seperate parsing phase is used to fully validate the input contained in the returned val_value_t structs.
This parsing phase checks that simple types are complete and child members of complex types are valid (but maybe missing or incomplete child nodes).
buff | zero-terminated buffer to parse | |
obj | obj_template_t for the object to parse | |
[out] | returnQ | address of Q to store parsed value results
|
status_t json_parse_text | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
obj_template_t * | obj, | ||
dlq_hdr_t * | returnQ | ||
) |
Parse token chain representing JSON Text.
This function assumes that the msg->tkc token control block has been setup correctly in advance
tkc = tk_new_chain(); tk_setup_chain_json_buffs(tkc, ...); (example!) tk_tokenize_input(tkc);
Makes sure that only allowed value strings or child nodes (and their values) are entered.
Defaults are not added to any objects Missing objects are not checked
A separate parsing phase is used to fully validate the input contained in the returned val_value_t structs.
This parsing phase checks that simple types are complete and child members of complex types are valid (but maybe missing or incomplete child nodes).
scb | session control block | |
[in,out] | msg | xml_msg header from the incoming RPC message
|
obj | obj_template_t for the object to parse | |
[out] | returnQ | address of Q to store parsed value results
|
status_t json_parse_top_identifier | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
obj_template_t * | obj, | ||
const xmlChar ** | modname, | ||
const xmlChar ** | name, | ||
xmlChar ** | tempbuff | ||
) |
Parse a top-level JSON object;.
will be used only for the DATASTORE launchpoint in order to set request_target and obj
scb | session control block Input is read from scb->reader. | |
msg | incoming RPC message Errors are appended to msg->errQ | |
obj | object template to use for parsing | |
modname | return module name pointer, may be NULL
| |
[out] | name | return pointer to name of the node
|
[out] | tempbuff | buffer to write, must be freed by caller
|
void json_wr_check_child_obj | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
val_value_t * | val, | ||
obj_template_t * | objnode, | ||
int32 | indent, | ||
val_nodetest_fn_t | testfn, | ||
boolean | isfirst, | ||
boolean | isfirstchild | ||
) |
generate entire val_value_t *w/filter)
Write an entire <get2> val_value_t out from the obj_template_t callback Using an optional testfn to filter output
scb | session control block |
msg | xml_msg_hdr_t in progress |
val | parent of the object to write |
objnode | child object node to write |
indent | start indent amount if indent enabled |
testfn | callback function to use, NULL if not used |
isfirst | first node printed |
isfirstchild | isfirstchild of whatever container |
void json_wr_check_child_obj_ex | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
getcb_get2_t * | parent_get2cb, | ||
obj_template_t * | objnode, | ||
int32 | indent, | ||
val_nodetest_fn_t | testfn, | ||
boolean | isfirst, | ||
boolean | isfirstchild | ||
) |
generate entire val_value_t *w/filter) (extended version)
Write an entire <get2> val_value_t out from the obj_template_t callback Using an optional testfn to filter output.
scb | session control block |
msg | xml_msg_hdr_t in progress |
parent_get2cb | parent get2 control block of the object to write |
objnode | child object node to write |
indent | start indent amount if indent enabled |
testfn | callback function to use, NULL if not used |
isfirst | first node printed |
isfirstchild | isfirstchild of whatever container |
status_t json_wr_check_file | ( | const xmlChar * | filespec, |
val_value_t * | val, | ||
int32 | startindent, | ||
int32 | indent, | ||
val_nodetest_fn_t | testfn | ||
) |
Write the specified value to a FILE in JSON format.
filespec | exact path of filename to open |
val | value for output |
startindent | starting indent point |
indent | indent amount (0..9 spaces) |
testfn | callback test function to use |
status_t json_wr_check_file2 | ( | const xmlChar * | filespec, |
val_value_t * | val, | ||
int32 | startindent, | ||
int32 | indent, | ||
val_nodetest_fn_t | testfn, | ||
boolean | modnames | ||
) |
Write the specified value to a FILE in JSON format.
filespec | exact path of filename to open |
val | value for output |
startindent | starting indent point |
indent | indent amount (0..9 spaces) |
testfn | callback test function to use |
modnames | TRUE for IETF-JSON; FALSE for plain JSON |
status_t json_wr_check_open_file | ( | FILE * | fp, |
val_value_t * | val, | ||
int32 | startindent, | ||
int32 | indent, | ||
val_nodetest_fn_t | testfn | ||
) |
Write the specified value to an open FILE in JSON format.
fp | open FILE control block |
val | value for output |
startindent | starting indent point |
indent | indent amount (0..9 spaces) |
testfn | callback test function to use |
status_t json_wr_check_open_file2 | ( | FILE * | fp, |
val_value_t * | val, | ||
int32 | startindent, | ||
int32 | indent, | ||
val_nodetest_fn_t | testfn, | ||
boolean | modnames | ||
) |
Write the specified value to an open FILE in JSON format Allow JSON or JSON-IETF format.
fp | open FILE control block |
val | value for output |
startindent | starting indent point |
indent | indent amount (0..9 spaces) |
testfn | callback test function to use |
modnames | TRUE for IETF-JSON; FALSE for plain JSON |
void json_wr_end_array | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
int32 | startindent | ||
) |
generate end of a JSON array
scb | session control block |
msg | xml_msg_hdr_t in progress |
startindent | start indent amount if indent enabled |
void json_wr_end_object | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
int32 | startindent | ||
) |
generate end of a JSON object
scb | session control block |
msg | xml_msg_hdr_t in progress |
startindent | start indent amount if indent enabled |
status_t json_wr_file | ( | const xmlChar * | filespec, |
val_value_t * | val, | ||
int32 | startindent, | ||
int32 | indent | ||
) |
Write the specified value to a FILE in JSON format.
filespec | exact path of filename to open |
val | value for output |
startindent | starting indent point |
indent | indent amount (0..9 spaces) |
status_t json_wr_file2 | ( | const xmlChar * | filespec, |
val_value_t * | val, | ||
int32 | startindent, | ||
int32 | indent, | ||
boolean | modnames | ||
) |
Write the specified value to a FILE in JSON format.
filespec | exact path of filename to open |
val | value for output |
startindent | starting indent point |
indent | indent amount (0..9 spaces) |
modnames | TRUE for IETF-JSON; FALSE for plain JSON |
status_t json_wr_full_check_val | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
xmlns_id_t | parent_nsid, | ||
val_value_t * | val, | ||
int32 | startindent, | ||
val_nodetest_fn_t | testfn | ||
) |
generate entire val_value_t *w/filter)
Write an entire val_value_t out as XML, including the top level Using an optional testfn to filter output
scb | session control block |
msg | xml_msg_hdr_t in progress |
parent_nsid | parent namespace ID; used if val->parent NULL |
val | value to write |
startindent | start indent amount if indent enabled |
testfn | callback function to use, NULL if not used |
status_t json_wr_full_check_val_force | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
xmlns_id_t | parent_nsid, | ||
val_value_t * | val, | ||
int32 | startindent, | ||
val_nodetest_fn_t | testfn, | ||
xmlns_id_t | force_nsid, | ||
const xmlChar * | force_name | ||
) |
generate entire val_value_t *w/filter)
Write an entire val_value_t out as JSON, including the top level Using an optional testfn to filter output Force top-node nsid/name if set
scb | session control block |
msg | xml_msg_hdr_t in progress |
parent_nsid | parent namespace ID; used if val->parent NULL |
val | value to write |
startindent | start indent amount if indent enabled |
testfn | callback function to use, NULL if not used |
force_nsid | top-level NSID to use instead of val (if set) |
force_name | top-level name to use instead of val (if set) |
status_t json_wr_max_check_val | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
xmlns_id_t | parent_nsid, | ||
val_value_t * | val, | ||
int32 | startindent, | ||
val_nodetest_fn_t | testfn, | ||
boolean | isfirst, | ||
boolean | islast, | ||
boolean | isfirstchild, | ||
boolean | isfirstsibling, | ||
boolean | force_lastsibling, | ||
boolean | force_lastsib_value, | ||
boolean | force_array_obj | ||
) |
generate entire val_value_t *w/filter)
Write an entire val_value_t out as XML, including the top level Using an optional testfn to filter output Maximum parameters exposed
scb | session control block |
msg | xml_msg_hdr_t in progress |
parent_nsid | parent namespace ID; used if val->parent NULL |
val | value to write |
startindent | start indent amount if indent enabled |
testfn | callback function to use, NULL if not used |
isfirst | TRUE if this is the first (top) val printed |
islast | TRUE if this is the last (top) val printed |
isfirstchild | TRUE if this is the first child of a parent node FALSE if this is the 2nd - Nth value of an array |
isfirstsibling | TRUE if this is the first value of an array FALSE if this is the 2nd - Nth value of an array |
force_lastsibling | TRUE to force this as the last sibling; TRUE or FALSE to check the sibling of 'val' |
force_lastsib_value | TRUE to force this as the last sibling FALSE to force this as not the last sibling; ignore if force_lastsibling is FALSE |
force_array_obj | TRUE to treat select leafs and containers as leaf-lists and lists which normally have only 1 instance in their actual context, but select removes the context |
status_t json_wr_max_check_val_force | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
xmlns_id_t | parent_nsid, | ||
val_value_t * | val, | ||
int32 | startindent, | ||
val_nodetest_fn_t | testfn, | ||
boolean | isfirst, | ||
boolean | islast, | ||
boolean | isfirstchild, | ||
boolean | isfirstsibling, | ||
boolean | force_lastsibling, | ||
boolean | force_lastsib_value, | ||
boolean | force_array_obj, | ||
xmlns_id_t | force_nsid, | ||
const xmlChar * | force_name | ||
) |
generate entire val_value_t *w/filter)
Write an entire val_value_t out as JSON, including the top level Using an optional testfn to filter output Maximum parameters exposed Force top-node nsid/name if set
scb | session control block |
msg | xml_msg_hdr_t in progress |
parent_nsid | parent namespace ID; used if val->parent NULL |
val | value to write |
startindent | start indent amount if indent enabled |
testfn | callback function to use, NULL if not used |
isfirst | TRUE if this is the first (top) val printed |
islast | TRUE if this is the last (top) val printed |
isfirstchild | TRUE if this is the first child of a parent node FALSE if this is the 2nd - Nth value of an array |
isfirstsibling | TRUE if this is the first value of an array FALSE if this is the 2nd - Nth value of an array |
force_lastsibling | TRUE to force this as the last sibling; TRUE or FALSE to check the sibling of 'val' |
force_lastsib_value | TRUE to force this as the last sibling FALSE to force this as not the last sibling; ignore if force_lastsibling is FALSE |
force_array_obj | TRUE to treat select leafs and containers as leaf-lists and lists which normally have only 1 instance in their actual context, but select removes the context |
force_nsid | top-level NSID to use instead of val (if set) |
force_name | top-level name to use instead of val (if set) |
void json_wr_output_null | ( | ses_cb_t * | scb, |
int32 | startindent | ||
) |
generate a null value; needed for printing empty <data> element which is done as a wrapper, not a real value node
scb | session control block |
startindent | start indent amount if indent enabled |
void json_wr_simval_line | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
xmlns_id_t | nsid, | ||
const xmlChar * | namestr, | ||
const xmlChar * | valstr, | ||
ncx_btype_t | btyp, | ||
int32 | startindent, | ||
boolean | isfirst | ||
) |
generate 1 line for a simple value within a container or array
scb | session control block |
msg | xml_msg_hdr_t in progress |
nsid | active namespace ID |
namestr | complete name string
|
valstr | value string to write (NULL for empty types) |
btyp | basetype of the value before translated to string |
startindent | start indent amount if indent enabled |
isfirst | == TRUE if this is the first line; FALSE if not |
void json_wr_start_array | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
int32 | startindent | ||
) |
generate start of a JSON array
scb | session control block |
msg | xml_msg_hdr_t in progress |
startindent | start indent amount if indent enabled |
void json_wr_start_array_obj | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
const xmlChar * | modname, | ||
const xmlChar * | name, | ||
obj_template_t * | obj, | ||
int32 | startindent, | ||
boolean | startbrace, | ||
boolean | startbracket | ||
) |
generate start of a JSON array; use OBJ to check the modname
scb | session control block |
msg | xml_msg_hdr_t in progress |
modname | module name of JSON object (NULL to omit) |
name | name of JSON object |
obj | object to use |
startindent | start indent amount if indent enabled |
startbrace | TRUE to print start brace |
startbracket | TRUE to print start bracket |
void json_wr_start_array_val | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
val_value_t * | val, | ||
int32 | startindent, | ||
boolean | startbrace, | ||
boolean | startbracket | ||
) |
generate start of a JSON array; use value node
scb | session control block |
msg | xml_msg_hdr_t in progress |
val | value node to output |
startindent | start indent amount if indent enabled |
startbrace | TRUE to print start brace |
startbracket | TRUE to print start bracket |
void json_wr_start_object | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
const xmlChar * | modname, | ||
const xmlChar * | name, | ||
int32 | startindent | ||
) |
generate start of a JSON object
scb | session control block to use for writing |
msg | xml_msg_hdr_t in progress |
modname | module name of JSON object (NULL to omit) |
name | name of JSON object |
startindent | start indent amount if indent enabled |
void json_wr_start_object_ex | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
const xmlChar * | modname, | ||
const xmlChar * | name, | ||
int32 | startindent, | ||
boolean | startbrace, | ||
boolean | endbrace | ||
) |
generate start of a JSON object (extended version)
scb | session control block to use for writing |
msg | xml_msg_hdr_t in progress |
modname | module name of JSON object (NULL to omit) |
name | name of JSON object |
startindent | start indent amount if indent enabled |
startbrace | TRUE to print start brace |
endbrace | TRUE to print start brace |
void json_wr_start_object_obj | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
const xmlChar * | modname, | ||
const xmlChar * | name, | ||
obj_template_t * | obj, | ||
int32 | startindent | ||
) |
generate start of a JSON object based on val value tree; use OBJ to check the modname
scb | session control block to use for writing |
msg | xml_msg_hdr_t in progress |
modname | module name of JSON object (NULL to omit) |
name | name of JSON object |
obj | object template to use for JSON start |
startindent | start indent amount if indent enabled |
void json_wr_start_object_val | ( | ses_cb_t * | scb, |
xml_msg_hdr_t * | msg, | ||
val_value_t * | val, | ||
int32 | startindent | ||
) |
generate start of a JSON object based on val value tree
Generate start JSON for a val_value_t struct
scb | session control block |
msg | xml_msg_hdr_t in progress |
val | value node to output |
startindent | start indent amount if indent enabled |