Scroll to navigation

jwt_helpers_get_grp(3) Library Functions Manual jwt_helpers_get_grp(3)

NAME

jwt_helpers_get_grp - Getters

SYNOPSIS

Macros


#define jwt_set_GET_INT(__v, __n)
Setup a jwt_value_t to get an integer value. #define jwt_set_GET_STR(__v, __n)
Setup a jwt_value_t to get a string value. #define jwt_set_GET_BOOL(__v, __n)
Setup a jwt_value_t to get a boolean value. #define jwt_set_GET_JSON(__v, __n)
Setup a jwt_value_t to get a JSON string.

Detailed Description

When getting a value, you must set type and name. On a successful return, the the value specific to the type will be filled in. Common error responses for this function are JWT_VALUE_ERR_NOEXIST when the name does not exist, and JWT_VALUE_ERR_TYPE, when the named object is not of the type you requested (e.g. you requested a string, but it's an integer value).

Remarks

When getting a JSON value, you can set value.name = NULL, in which case the entire header is returned. Also, the resulting value.json_val will be using allocated memory and must be freed by the caller.

Note

Normally JSON is retrieved in compact form. If you set jwt_value_t.pretty, then you will get a tabbed format suitable for human viewing. This must be set after calling jwt_set_GET_JSON().

jwt_value_error_t ret;
jwt_value_t jval;
jwt_set_GET_INT(&jval, "h1");
ret = jwt_builder_claim_get(builder, &jval);
if (ret == JWT_VALUE_ERR_NONE)

printf("h1 = %d\n", jval.int_val);

Macro Definition Documentation

#define jwt_set_GET_BOOL(__v, __n)

Value:.PP


({ \
(__v)->type=JWT_VALUE_BOOL; \
(__v)->name=(__n);(__v)->bool_val=0;(__v)->error=0;\
(__v);})

Setup a jwt_value_t to get a boolean value.

Parameters

__v Pointer to a jwt_value_t object
__n Name of the value

Returns

No return value

#define jwt_set_GET_INT(__v, __n)

Value:.PP


({ \
(__v)->type=JWT_VALUE_INT; \
(__v)->name=(__n);(__v)->int_val=0;(__v)->error=0;\
(__v);})

Setup a jwt_value_t to get an integer value.

Parameters

__v Pointer to a jwt_value_t object
__n Name of the value

Returns

No return value

#define jwt_set_GET_JSON(__v, __n)

Value:.PP


({ \
(__v)->type=JWT_VALUE_JSON;(__v)->pretty=0; \
(__v)->name=(__n);(__v)->json_val=NULL;(__v)->error=0;\
(__v);})

Setup a jwt_value_t to get a JSON string.

Parameters

__v Pointer to a jwt_value_t object
__n Name of the value

Returns

No return value

#define jwt_set_GET_STR(__v, __n)

Value:.PP


({ \
(__v)->type=JWT_VALUE_STR; \
(__v)->name=(__n);(__v)->str_val=NULL;(__v)->error=0;\
(__v);})

Setup a jwt_value_t to get a string value.

Parameters

__v Pointer to a jwt_value_t object
__n Name of the value

Returns

No return value

Author

Generated automatically by Doxygen for LibJWT from the source code.

Version 3.2.2 LibJWT