-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
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.