Closed ChivenZhang closed 2 years ago
Why use picojson instead of nlohmann JSON ?
Thats a decision you make, not jwt-cpp. jwt-cpp supports a number of json libraries.
I really want to use jwt-cpp, but it would import other dependency with same json function
jwt-cpp can work with nlohmann json. What you need to do is include one of the traits files instead of the default jwt-cpp header. You can see an example of how to use nlohmann json here: https://github.com/Thalhammer/jwt-cpp/blob/c9a511f436eaa13857336ebeb44dbc5b7860fe01/example/traits/nlohmann-json.cpp
Did picojson has better performance or other good reason?
Picojson is the default option because at the time I initially wrote the library it was the one I was familiar with and was the easiest to drop in. However as jwt-cpp became usefull for a wider audience it was rewritten to support basically any json library using traits. We currently ship with first hand (tested) support for boost-json
,danielaparker's jsoncons
, nlohmann json
as well picojson
, which remains the default for backwards compatibility reasons. jwt-cpp has managed to stay more or less api compatible over its entire lifetime, despite its internals changing quite drastically and I'd like to keep it this way, so the default won't go away any time soon. However as they are really just default options you can easily switch them and jwt-cpp will work just fine with a number of different configurations.
Apart from the json library you can also change:
I am closing this as I hope to have solved your question by pointing you the right direction, feel free to reopen it if you still have issues.
You can seen an example of how to use nlohmann json here: https://github.com/Thalhammer/jwt-cpp/blob/c9a511f436eaa13857336ebeb44dbc5b7860fe01/example/traits/nlohmann-json.cpp
What's your question?
Why use picojson instead of nlohmann JSON ?
Additional Context
My project had integrated nlohmann json library in other module. I really want to use jwt-cpp, but it would import other dependency with same json function,I am confused about that why not use most popular json lib. Did picojson has better performance or other good reason? Thanks.