Can I get objects by name with libjson?

123 Views Asked by At

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?

1

There are 1 best solutions below

0
On

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.