Skip to content

No way to get location of string key in a parsed file #1283

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

Open
KyleFromKitware opened this issue Apr 9, 2021 · 0 comments
Open

No way to get location of string key in a parsed file #1283

KyleFromKitware opened this issue Apr 9, 2021 · 0 comments

Comments

@KyleFromKitware
Copy link

Is your feature request related to a problem? Please describe.
I would like to be able to determine exactly where in a file a string key in an object came from, so that I can emit useful error messages related to the contents of the key itself (not the value associated with it).

Describe the solution you'd like
I would like to add four new member functions to Json::Value:

  void setKeyOffsetStart(const char* begin, const char* end, ptrdiff_t start);
  void setKeyOffsetLimit(const char* begin, const char* end, ptrdiff_t limit);
  ptrdiff_t getKeyOffsetStart(const char* begin, const char* end) const;
  ptrdiff_t getKeyOffsetLimit(const char* begin, const char* end) const;

These are based on, and functionally similar to, setOffsetStart(), setOffsetLimit(), getOffsetStart(), and getOffsetLimit().

Describe alternatives you've considered
I could use getOffsetStart() and getOffsetLimit() to get the location of the value associated with the key, which would at least put the user in the vicinity of the key that they need to inspect. However, getting the location of the key itself (in case it's on a different line than the value) would be more ideal.

Additional context
I am trying to make some of CMake's error messages regarding errors in JSON files more detailed and helpful, but am running into limits from jsoncpp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant