0

Can I get objects by name with libjson?

I have installed libjson. I am surprised there is no way to get values by object name. I will have to write my own functions or am I missing something?

user3111311
  • 7,583
  • 7
  • 33
  • 48

1 Answers1

0

If you are using the C++ library, the JSONNode class overloads the [] operator.

Per the docs:

JSONNode & operator [] (const json_string & name);
const JSONNode & operator [] (const json_string & name) const;

This will give you a reference to a child node either at a specific location or by it’s name. Asking for a
node that is not there will result in undefined behavior.
wshirey
  • 113
  • 6