Closed VitaminCpp closed 5 years ago
Hi @pmed,
do you know how we can solve this issue ?
Thank you very much!
As I understand, it's possible to set [toJSON()
](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON()_behavior) function in a JavaScript class protoptype, and such a function would be invoked on JSON.stringify()
call for the corresponding instance.
I've updated v8pp::class_
test to check this behavior.
This looks very promising, thank you! Do you think we could implement this for every exported class automatically ?
I've added a pull request for a generic version #96. Plz have a look :) Thx!
Fixed in #96
I've exported a simple class like this...
...
In Javascript I now want to convert this object to JSON:
But this simply outputs an empty object "{}" instead of "{ var1: "dummyString" }". I think this issue has something to do with "enumerable properties"? So what do I have to do to convert an exported C++ object to JSON?