-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Get string field content without return std::string copy #2091
Comments
I am fully aware of the fact that the returned char* may be invalidate when the json object is altered later. It's the client's responsbility to use the returned raw string properly, is ther any way to get it ? |
just take the std::string return and to |
this required a std::string copy as well. I want the content without any copy.. |
This works: json j = "Hello";
auto s = j.get_ref<std::string&>().c_str(); |
due to compatbility reason, I need to use version 2.1.1, and seems this version does not support such operation. how to achieve this in version 2.1.? |
According to the Release Notes, |
Cool, I got build error and though it was caused by no such definition. I checked the code, my issue was not provide const before std::string reference, because my input json j is a const object. |
Cool! (But you really should update to the recent version...) |
This is why I use submodules makes update just a |
This depends on your policies of how updates are made. But yes, this may be a convenient method. |
this is not quite a safe way for large project, since it may introduce new features automatically that may break existing functionality. I prefer to test intensively before mannually upgrade to new version. |
Will check and upgarade. :-) |
@zmwangcode I mean if it did not work out you can always |
I am dealing with json with a lot of string fields, I checked the souce code , seems there is no way to get the underlying string of string field without a std::string copy?
auto content = j.get<char*>()
Something likes this will be very helpful.
The text was updated successfully, but these errors were encountered: