Closed bartoszmodelski closed 8 months ago
jwt-cpp is built around the concept of having replaceable json/crypto libraries and as a result of that needs to know which one you are using. You can do this by either including the default.h of one of the traits (like you did, note that it implicitly includes the main header, so you only need default.h) or by explicitly specifying the traits as part of the decode/create functions (which is what the error is trying to tell you, you are missing the template parameter).
What the default.h headers do is include the traits and jwt header and declaring the trait as a default template parameter, which allows you to skip specifying it.
So yes, this is expected behaviour. It used to be different a long time ago when jwt-cpp relied exclusively on picojson and it used to include the picojson traits as a default for a while after (unless you explicitly disabled it), however for a couple of releases now this is how it works.
What's your question?
No idea if this is expected (if so, apologies for the noise) or not, feel free to close. In any case, that should make the error googleable for other novices.
Additional Context
The basic example failed to compile for me:
Fixed by linking
nlohman_json
(or other supported json libs, I presume) and including trait defaults:#include <jwt-cpp/traits/nlohmann-json/defaults.h>
.