Cheerp is a C++ to js/wasm transpiler.
Using C++, I am able to interface with extern
Javascript objects by statically defining a type and name of an object (and it's members).
Take the following object as an example:
var example1 = {
"itemA" : {
value : 3
},
"itemB" : {
value : 1
},
"item3165942" : {
value : 4
}
}
It would be trivial to statically define example1
as a struct with itemA/itemB as sub-structs. But I would never be able to access example1["item3165942"]
.
How do I dynamically retrieve, index and iterate over a javascript object's keys/values from within C++? Assume that all items in example1
are the following type:
struct item_type {
int32_t value;
};