So I have this duktape function which accepts an object as one of the parameters. Under normal circumstances, to retrieve the values of each of the objects attributes, I would use duk_get_prop()
and duk_push_string()
, however this assumes I know beforehand the structure of the object I am getting.
Now, consider a function which accepts an object with an unknown structure. I need to iterate over its keys, and retrieve all of its values.
I am trying to convert such an object to a C++ std::map<string, string>
For example, calling from Javascript
myFunction({x: 1, y: 3, z: 35})
should work as well as myFunction({foo: 12, bar: 43})
.
It seems that duk_enum()
would be an appropriate function for this, but I am not quite understanding how it works.