You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
I'm using your library in my projects and i really like it.
But on the other hand it's basic_object<> implicit conversions from string is a source of bugs and long debugging sessions. I had two such sessions today.
Take a look. Some time ago a had a settings_provider class and a test mock
But the EXPECT_CALL continued to compile,but now get_settings returns json object with value "{ "key"="value" }".
So, my suggestion is to make conversion from string(and maybe other types) explicit, to avoid such errors in future.
The text was updated successfully, but these errors were encountered:
I don't think we can mark the constructor explicit (especially since there is only one constructor for almost every type now), this would break everyone's code.
I know that implicit conversions are a source of bugs, but in this case the _json suffix seems to be the best way to fix that kind of issues
I also run into a similar issue when first tried doing something like this: string smsg((char*)buff, len); json jmsg{smsg}; or json jmsg = smsg; or something.
I think what would help, is adding a note in the documentation here
// Note the '_json' at the end of the string
json j = "{ \"happy\": true, \"pi\": 3.141 }"; /// will not parse std::string, you need to use json::parse for that
Implicit conversion is one of the major aspect that makes the library usable. Unfortunately, here the "wrong" string-to-JSON conversion has been chosen. I shall add a comment to the documentation to make this clearer.
Hi!
I'm using your library in my projects and i really like it.
But on the other hand it's basic_object<> implicit conversions from string is a source of bugs and long debugging sessions. I had two such sessions today.
Take a look. Some time ago a had a settings_provider class and a test mock
Then,when using this mock,i setup it to return some json-formatted string
Some time later i changed settings_provider and corresponding mock interface to
But the EXPECT_CALL continued to compile,but now get_settings returns json object with value "{ "key"="value" }".
So, my suggestion is to make conversion from string(and maybe other types) explicit, to avoid such errors in future.
The text was updated successfully, but these errors were encountered: