-
Notifications
You must be signed in to change notification settings - Fork 42
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
keep nlohmann::json private #371
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,7 +175,8 @@ TEST_CASE("UserInfoClaims Field Parsing") | |
{ "updated_at", 42 } | ||
}; | ||
|
||
const auto userinfo_claims = UserInfoClaims::from_json(credentialSubject); | ||
const auto userinfo_claims = | ||
UserInfoClaims::from_json(credentialSubject.dump()); | ||
Comment on lines
+178
to
+179
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same raw string trick here. (Raw strings can span multiple lines.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am using the original json as the known answer for the tests. The tests in that section seem to only test that the strings get shuffled around correctly. |
||
|
||
CHECK(userinfo_claims.sub == credentialSubject.at("sub")); | ||
CHECK(userinfo_claims.name == credentialSubject.at("name")); | ||
|
@@ -214,14 +215,14 @@ TEST_CASE("UserInfoClaims Field Parsing") | |
TEST_CASE("UserInfoClaims Edge Cases") | ||
{ | ||
CHECK_THROWS_WITH( | ||
UserInfoClaims::from_json({ { "updated_at", "42" } }), | ||
UserInfoClaims::from_json(R"({"updated_at": "42"})"), | ||
"[json.exception.type_error.302] type must be number, but is string"); | ||
|
||
CHECK_THROWS_WITH( | ||
UserInfoClaims::from_json({ { "name", true } }), | ||
UserInfoClaims::from_json(R"({"name": true})"), | ||
"[json.exception.type_error.302] type must be string, but is boolean"); | ||
|
||
CHECK_THROWS_WITH( | ||
UserInfoClaims::from_json({ { "email_verified", "true" } }), | ||
UserInfoClaims::from_json(R"({"email_verified": "true"})"), | ||
"[json.exception.type_error.302] type must be boolean, but is string"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love this back and forth between strings and JSON. Maybe there's some way to have static functions that take
json
? So that they're hidden from callers but we can still use them.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the difficult thing about this library. If we have any use of our json library in the public api's then the consumer will have to build and link to our json library. If they use another library then they would have to convert. I think you understand that. I will think about the static function that might do the conversion. Out only options in the signature of a function is string or bytes. what do you have in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I had in mind was something like: