Setters
JSON Web Token » Claims and Headers » Utility Functions
Collaboration diagram for Setters:

## Macros

#define | jwt_set_SET_INT(__v, __n, __x)
| Setup a jwt_value_t to set an integer value.
#define | jwt_set_SET_STR(__v, __n, __x)
| Setup a jwt_value_t to set a string value.
#define | jwt_set_SET_BOOL(__v, __n, __x)
| Setup a jwt_value_t to set a boolean value.
#define | jwt_set_SET_JSON(__v, __n, __x)
| Setup a jwt_value_t to set a JSON string.

## Detailed Description

When setting a value, you must set the type, name, and the specific val for the type. If the value already exists, then the function will return JWT_VALUE_ERR_EXISTS and value.error will be set the same. If value.replace is non-zero, then any existing value will be overwritten.

Remarks
  When setting a JSON value, you can set value.name = NULL, in which case the entire header will be set to the JSON string pointed to by value.json_val. If value.replace is not set, only values that do not already exist will be set. If replace is set, then existing values will also be updated. There is no indication of which values are or aren't updated in either case.

Note
  The replace flag must be set after calling jwt_set_SET_*() macro, as the macros will reset it back to 0.

jwt_value_error_t ret;
jwt_value_t jval;
jwt_set_SET_STR(&jval, "iss", "foo.example.com");
ret = jwt_builder_header_set(jwt, &jval);
if (ret == JWT_VALUE_ERR_NONE)
printf("iss updated to: %s\n", jval.str_val);
jwt_builder_header_set
jwt_value_error_t jwt_builder_header_set(jwt_builder_t *builder, jwt_value_t *value)
Set a header in 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_SET_STR
#define jwt_set_SET_STR(__v, __n, __x)
Setup a jwt_value_t to set a string value.
Definition jwt.h:793
jwt_value_t
Data type for get and set actions for JWT headers and claims.
Definition jwt.h:187
jwt_value_t::str_val
const char * str_val
Definition jwt.h:192

## Macro Definition Documentation

## jwt_set_SET_BOOL

#define jwt_set_SET_BOOL | ( |  | __v,
|  |  | __n,
|  |  | __x )

Value:
({ \
(__v)->type=JWT_VALUE_BOOL;(__v)->replace=0; \
(__v)->name=(__n);(__v)->bool_val=(__x);(__v)->error=0;\
(__v);})
JWT_VALUE_BOOL
@ JWT_VALUE_BOOL
Definition jwt.h:160

Setup a jwt_value_t to set a boolean value.

Parameters

  __v | Pointer to a jwt_value_t object
  __n | Name of the value
  __x | Value to set

Returns
  No return value

## jwt_set_SET_INT

#define jwt_set_SET_INT | ( |  | __v,
|  |  | __n,
|  |  | __x )

Value:
({ \
(__v)->type=JWT_VALUE_INT;(__v)->replace=0; \
(__v)->name=(__n);(__v)->int_val=(__x);(__v)->error=0;\
(__v);})
JWT_VALUE_INT
@ JWT_VALUE_INT
Definition jwt.h:158

Setup a jwt_value_t to set an integer value.

Parameters

  __v | Pointer to a jwt_value_t object
  __n | Name of the value
  __x | Value to set

Returns
  No return value

## jwt_set_SET_JSON

#define jwt_set_SET_JSON | ( |  | __v,
|  |  | __n,
|  |  | __x )

Value:
({ \
(__v)->type=JWT_VALUE_JSON;(__v)->replace=0; \
(__v)->name=(__n);(__v)->json_val=(__x);(__v)->error=0; \
(__v);})
JWT_VALUE_JSON
@ JWT_VALUE_JSON
Definition jwt.h:161

Setup a jwt_value_t to set a JSON string.

Parameters

  __v | Pointer to a jwt_value_t object
  __n | Name of the value
  __x | Value to set

Returns
  No return value

## jwt_set_SET_STR

#define jwt_set_SET_STR | ( |  | __v,
|  |  | __n,
|  |  | __x )

Value:
({ \
(__v)->type=JWT_VALUE_STR;(__v)->replace=0; \
(__v)->name=(__n);(__v)->str_val=(__x);(__v)->error=0;\
(__v);})
JWT_VALUE_STR
@ JWT_VALUE_STR
Definition jwt.h:159

Setup a jwt_value_t to set a string value.

Parameters

  __v | Pointer to a jwt_value_t object
  __n | Name of the value
  __x | Value to set

Returns
  No return value