You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using v1.6.2 of the jsoncpp library on aWin32 platform. All's well, I'm able to parse json and access Json:Values successfully using v.["firstname"] etc.
Q: How do I find a Json:Value by name in a json structure? In the documentation I've found:
but it doesn't specify what 'end' is. I've tried "", NULL etc, but it's throwing exceptions if I try to access the Value it returns.
Good question. We should clarify the docs, and maybe rename key to begin.
end is similar to begin/end in STL. It is one past the end of your string. If you have a null-terminated array, you can do this:
v.find(mycstring, mystring + strlen(mycstring));
WIth a std::string:
v.find(mystdstring.begin(), mystdstring.end());
Should I even be trying to find things this way?
Yes, it's the right API. The reason for the oddness is that we do not want anyone to rely on null-terminated c-strings, since they preclude UTF-8 with embedded zeroes.
The text was updated successfully, but these errors were encountered:
Thanks - those suggestions work nicely. However I'm also finding that find is returning bool rather than the Value I'm trying to find. This is the reason I'm throwing exceptions when trying to access members. Is this correct? If so it might be helpful to update the documentation with this also. (I think I should be using get or one of the [] operators instead. I'll get the hang of this eventually!)
Bob wrote:
Good question. We should clarify the docs, and maybe rename
key
tobegin
.end
is similar to begin/end in STL. It is one past the end of your string. If you have a null-terminated array, you can do this:WIth a
std::string
:Yes, it's the right API. The reason for the oddness is that we do not want anyone to rely on null-terminated c-strings, since they preclude UTF-8 with embedded zeroes.
The text was updated successfully, but these errors were encountered: