Skip to content

glz::json_t trait support #391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

StormLord07
Copy link

  • added a trait support for glz::json_t, map like glaze object jwt::traits::stephenberry_glaze
  • and a default.h file

@Thalhammer
Copy link
Owner

Hi and thank you for showing interest in extending jwt-cpp's support for json libraries.
Would it be possible to add some CI testing to ensure we don't break any of the code in the future ?
In addition the CMake scripts need modification to ensure the new files are correctly installed along the other headers.

@StormLord07
Copy link
Author

@Thalhammer I’ve added tests. Glaze is usually installed via FetchContent, but it can be found using find_package. I used find_package like in other tests, though it can't be installed via apt and has to be built from source and installed manually

A few points to mention:

  1. glz::json_t doesn’t store integer values, only doubles. I didn’t add special support for integers. The only workaround I can think of is checking if double == floor(double), which feels wrong because we might want 16.0 to not be the same as 16.
  2. There’s no support for string streams and operator>> with glz::json_t, so I had to change the test code. We could either add artificial support for it or i could try adding PR to Glaze, but that would take some time.

@StormLord07
Copy link
Author

It should work, unfortunately i cant fix it without changing already exisiting ci too much, its just JWT CI coverage fails on

geninfo: ERROR: mismatched end line for _ZN25BaseTest_Base64Index_Test8TestBodyEv at /home/runner/work/jwt-cpp/jwt-cpp/tests/BaseTest.cpp:4: 4 -> 20
	(use "geninfo --ignore-errors mismatch ..." to bypass this error)

the fix should be changinx tests CMake file with provding additional args to
setup_target_for_coverage_lcov(NAME coverage EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/jwt-cpp-test)

but

  • im not sure how do it properly
  • its outside of scope of this pr,

All other problems were mentioned before

  1. glz::json_t doesn’t store integer values, only doubles. I didn’t add special support for integers. The only workaround I can think of is checking if double == floor(double), which feels wrong because we might want 16.0 to not be the same as 16.
  2. There’s no support for string streams and operator>> with glz::json_t, so I had to change the test code. We could either add artificial support for it or i could try adding PR to Glaze, but that would take some time.

tests/traits/StephenberryGlazeTest.cpp:19
tests/traits/StephenberryGlazeTest.cpp:58

@Thalhammer
Copy link
Owner

Glaze is usually installed via FetchContent

Using FetchContent is also fine, we already do that for nlohmann json. If you do that it would be good to add a option to disable it so that people can turn it off if they don't want to use it.

so I had to change the test code.

That's perfectly fine for me. We don't guarantee/require any support from the json library except whats needed inside jwt-cpp or the trait itself.

its just JWT CI coverage fails on

Yeah that's known. Coverage broke a while ago due to version changes in githubs runners, I just haven't come around to update it yet. It's outside the scope of the PR, so don't worry about it ;)
If you are bored you are free to fix it in a different PR though.

@StormLord07
Copy link
Author

StormLord07 commented Aug 18, 2025

Do i need to do something else for it to get merged? Or I should just wait around till its merged?

I also tried to fix the CI/CD in another PR, but im not sure if i should have made the pr from the master of from this pr, so its from master and will most certanly have conflicts with this file in CMakeLists and the JWT workflow

@Thalhammer
Copy link
Owner

Do i need to do something else for it to get merged?

CMake needs a formating, see https://github.com/Thalhammer/jwt-cpp/actions/runs/17001690793/job/48229838158?pr=391 Other than that it should be fine to merge.

@StormLord07
Copy link
Author

Ah, that's what it means, I thought it just is unable to push into the repo, fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants