-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
json_pointer public push_back, pop_back #837
Comments
I think this addition makes sense - especially as reference tokens are stored inside a vector internally. |
- made pop_back public and added documentation - implemented push_back function and added documentation - added test cases
@HugoLopata I added the functions to a feature branch, see 516d4e6. Is this what you had in mind? |
Yes, exactly as expected. json::json_pointer ptr1("/foo/bar~0baz");
json::json_pointer ptr2;
ptr2.push_back("/foo/bar~0baz");
std::cout << "ptr1: " << ptr1.to_string() << '\n'; // /foo/bar~0baz
std::cout << "ptr2: " << ptr2.to_string() << '\n'; // /~1foo~1bar~00baz Consider also adding some examples with escape characters to the tests. |
Oh I did not think about escaping. What do you think? Should |
|
I am not fond of However I think adding both Whether these escape or not should depend on the most intuitive/expected outcome. I've never used JSON pointers, so this should be agreed upon by experienced users. Anyway we have to support both cases, so mimicking Boost.Filesystem decided to not have an I believe |
I agree that |
I will postpone a decision for this after the 3.0.0 release. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
ping |
I don't think there should be an alternative to Just like Concatenation is one of the most usual things to do with path-like objects, whereas removing a specific part is not done that often. Moreover, overloading |
We seem to circle around naming things...
Any more ideas? Furthermore, #837 (comment) needs to be addressed. |
I would go for variant 1 too, since |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I don't think that using Adding a few item to a jsoon_pointer would be
instead of A good way to achieve this without JSON pointers to match
Nothing would prevent additional constructors to be added for slash-separated strings, but I think that the user-defined literal is probably enough already for that. |
Please note that having both an operator and a member function is not incompatible, there is In this case, generic code could use |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I also need to split and concatenate and iterate over json_pointer elements. I think one could sidestep the escaping issue by only exposing json_pointers on the interface for that, not the underlying std::string. Where the conversion happens is then an implementation detail exposed only elsewhere. However, exposing the semantics of the underlying std::vector feels fine. If a json_pointer could walk and quack like a std::vector<json_pointer> with automatic flattening, things would be perfect. |
Thanks Niels for referring me to this issue. My PR is extremely simple and works. I have an itch right now, that I have to scratch. In my validator library I'm doing horrible things to append a key to a Here my suggestions: make pop_back() private again and add a Of course it would be nice to have similar interface as a |
Feature Request
I am generating some json pointers. It would be handy using push_back instead of composing string with slashes, which is subsequently broken to vector of strings by json_pointer.
Access to internal data may be handy too:
const vector<string>& json_pointer::impl() const;
The text was updated successfully, but these errors were encountered: