LibJWT 3.2.0
The C JSON Web Token Library +JWK +JWKS
Collaboration diagram for Getters:

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_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);
jwt_value_error_t jwt_builder_claim_get(jwt_builder_t *builder, jwt_value_t *value)
Get a claim from a builder object.
jwt_value_error_t
Error values for header and claim requests.
Definition jwt.h:162
@ JWT_VALUE_ERR_NONE
Definition jwt.h:163
#define jwt_set_GET_INT(__v, __n)
Setup a jwt_value_t to get an integer value.
Definition jwt.h:688
Data type for get and set actions for JWT headers and claims.
Definition jwt.h:181
long int_val
Definition jwt.h:185

Macro Definition Documentation

◆ jwt_set_GET_BOOL

#define jwt_set_GET_BOOL ( __v,
__n )
Value:
({ \
(__v)->type=JWT_VALUE_BOOL; \
(__v)->name=(__n);(__v)->bool_val=0;(__v)->error=0;\
(__v);})
@ JWT_VALUE_BOOL
Definition jwt.h:154

Setup a jwt_value_t to get a boolean value.

Parameters
__vPointer to a jwt_value_t object
__nName of the value
Returns
No return value

◆ jwt_set_GET_INT

#define jwt_set_GET_INT ( __v,
__n )
Value:
({ \
(__v)->type=JWT_VALUE_INT; \
(__v)->name=(__n);(__v)->int_val=0;(__v)->error=0;\
(__v);})
@ JWT_VALUE_INT
Definition jwt.h:152

Setup a jwt_value_t to get an integer value.

Parameters
__vPointer to a jwt_value_t object
__nName of the value
Returns
No return value

◆ jwt_set_GET_JSON

#define jwt_set_GET_JSON ( __v,
__n )
Value:
({ \
(__v)->type=JWT_VALUE_JSON;(__v)->pretty=0; \
(__v)->name=(__n);(__v)->json_val=NULL;(__v)->error=0;\
(__v);})
@ JWT_VALUE_JSON
Definition jwt.h:155

Setup a jwt_value_t to get a JSON string.

Parameters
__vPointer to a jwt_value_t object
__nName of the value
Returns
No return value

◆ jwt_set_GET_STR

#define jwt_set_GET_STR ( __v,
__n )
Value:
({ \
(__v)->type=JWT_VALUE_STR; \
(__v)->name=(__n);(__v)->str_val=NULL;(__v)->error=0;\
(__v);})
@ JWT_VALUE_STR
Definition jwt.h:153

Setup a jwt_value_t to get a string value.

Parameters
__vPointer to a jwt_value_t object
__nName of the value
Returns
No return value