LibJWT: Getters

| LibJWT 3.3.2 The C JSON Web Token Library +JWK +JWKS

Getters
JSON Web Token » Claims and Headers » Utility Functions
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_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);
jwt_builder_claim_get
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
jwt_value_error_t
Error values for header and claim requests.
Definition jwt.h:168
JWT_VALUE_ERR_NONE
@ JWT_VALUE_ERR_NONE
Definition jwt.h:169
jwt_set_GET_INT
#define jwt_set_GET_INT(__v, __n)
Setup a jwt_value_t to get an integer value.
Definition jwt.h:694
jwt_value_t
Data type for get and set actions for JWT headers and claims.
Definition jwt.h:187
jwt_value_t::int_val
jwt_long_t int_val
Definition jwt.h:191

## 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
@ JWT_VALUE_BOOL
Definition jwt.h:160

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

## ◆ 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
@ JWT_VALUE_INT
Definition jwt.h:158

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

## ◆ 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
@ JWT_VALUE_JSON
Definition jwt.h:161

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

## ◆ 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
@ JWT_VALUE_STR
Definition jwt.h:159

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