libjwt icon indicating copy to clipboard operation
libjwt copied to clipboard

Add iterator for grants.

Open warichet opened this issue 8 years ago • 2 comments

Hi, This is not a bug.

Need : In a nginx module i need to copy all grants in a context.

Pb: I haven't the defined list of grant key in this module.

Solution: Add iterator on grants to copy all grants without specified list of key.

Code: void *jwt_get_grant_iterator(jwt_t *jwt, void *iter) { if (!jwt) { errno = EINVAL; return NULL; } errno = 0;

if (iter == NULL) {
	return json_object_iter(jwt->grants);
}
return json_object_iter_next(jwt->grants, iter);

}

const char *jwt_iterator_key(void *iter) { return json_object_iter_key(iter); }

const char *jwt_iterator_value(void *iter) { json_t json = json_object_iter_value(iter); if (json == NULL) { return NULL; } return (const char)json_string_value(json); }

Best regards. Sebastien

warichet avatar Feb 22 '17 14:02 warichet

Would you be able to implement this on a pull request, complete with test cases?

Thanks

benmcollins avatar Aug 14 '17 14:08 benmcollins

Hi, no pb, i will do it. It is my first modification in github, that should takes a little over time.

Thanks Seb

warichet avatar Aug 28 '17 06:08 warichet