open-source-parsers / open-source-parsers/jsoncpp
Add support for std::string_view to Json::Value::operator[]
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 8.9k
- Forks
- 2.7k
- Avg merge
- 31m
- Merged PRs (30d)
- 1
Description
Is your feature request related to a problem? Please describe.
We use std::string_view for names of object entries. However, when accessing values with Json::Value::operator[], we always have to convert the name a std::string first. This incurs an unnecessary allocation and adds boilerplate code.
Describe the solution you'd like
I would like Json::Value::operator[] to support std::string_view.
Describe alternatives you've considered
As mentioned an alternative is to convert the name to std::string first, but this is less readable and slower. Converting to const char* is in general not possible, because the contents of std::string_view might not be null-terminated.
Additional context
This feature requires C++17. jsoncpp seems to build fine with C++17 so this shouldn't be a problem as long as the feature is deactivated when compiling with a lower standard.
https://github.com/open-source-parsers/jsoncpp/pull/999 already implemented this feature, but was closed. It is not clear to me why the PR was closed. If there is additional work necessary, I am happy to help.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the public Json::Value::operator[] entry point and review pull request #999 to understand the earlier implementation and why it was closed. Check how the library handles C++ standard compatibility and identify the relevant operator tests; done means std::string_view access works without requiring a std::string while lower language standards continue to build.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100