-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a test case for
JSON.stringify()
with wrapped class (issue #88)
According to the [`JSON.stringify()` documentation][1] it's possible to add a function `toJSON()` to prototype for custom conversion to JSON. Added a `Xbase::to_json()` functions and exposed it as `toJSON()` into v8, so that `JSON.stringify()` call for such objects would invoke the conversion function. Updated `create_X()` factory function to set the `X::var` on construction at JavaScript side. [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON()_behavior
- Loading branch information
Showing
1 changed file
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters