jwt_helpers_get_grp(3)

πŸ“¦
version 3.3.3 Β· 2 versions
, in ubuntu stonking

πŸ’– jwt_helpers_get_grp πŸ’–

okay bestie, so this is a page from the Library Functions Manual for jwt_helpers_get_grp β€” and yes the function name is giving "get the group" but it's actually the Getters page 🫢 it's all about pulling values out of a JWT, and honestly? it's iconic.


✨ NAME ✨

jwt_helpers_get_grp β€” Getters. that's it, that's the name. short, sweet, slays. πŸ’…


🌸 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.

four macros, four vibes, all of them little setup helpers πŸŽ€


πŸ‘‘ Detailed Description πŸ‘‘

so here's the tea πŸ“: when you're getting a value, you must set type and name. that's not optional, that's the rules. and on a successful return, the value specific to the type gets filled in for you. cute, right? πŸ’–

the common error responses for this function are:

  • JWT_VALUE_ERR_NOEXIST β€” when the name doesn't exist. it's literally not there bestie 😭
  • JWT_VALUE_ERR_TYPE β€” when the named object isn't the type you asked for (like, you requested a string but it's actually an integer value?? not the vibe πŸ’€)

πŸ™ˆ Remarks

when you're getting a JSON value, you can set value.name = NULL, and in that case the entire header is returned. also β€” and this is important, no cap β€” the resulting value.json_val will be using allocated memory and must be freed by the caller. don't forget to free it, bestie, or that memory is just gonna sit there. free it. periodt. 🧚

⭐ Note

normally JSON comes back in compact form. but if you set jwt_value_t.pretty, you get a tabbed format suitable for human viewing πŸ‘€βœ¨ and you have to set this after calling jwt_set_GET_JSON(). after, okay? after. πŸ™

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);

look at that. h1 goes in, JWT_VALUE_ERR_NONE comes out, and we print. main character energy honestly πŸ”₯


πŸ¦‹ Macro Definition Documentation πŸ¦‹

πŸ’œ #define jwt_set_GET_BOOL( __v, __n)

Value:

({  \
(__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:

({  \
(__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:

({          \
(__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. 🌈 and yup, it zeroes out pretty for you β€” remember the Note up there, you flip that after calling this one πŸ‘‘

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:

({  \
(__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. (not me writing any of this by hand, the robots did it πŸ€–βœ¨)


and that's the whole page bestie!! πŸ’… LibJWT, Version 3.3.3, and this was jwt_helpers_get_grp(3) β€” go forth and get those values, and please free your json_val πŸŒΈπŸ«ΆπŸ’œ

πŸ“¦ where this page comes from