Skip to content

Commit b335781

Browse files
authored
Update convert_json.hpp (#38)
1 parent 500ad0c commit b335781

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

include/xeus-javascript/convert_json.hpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,27 @@ struct BindingType<nl::json> {
1717
using ValBinding = BindingType<val>;
1818
using WireType = typename ValBinding::WireType;
1919

20+
#if __EMSCRIPTEN_major__ == 3 && __EMSCRIPTEN_major__ == 1 && __EMSCRIPTEN_tiny__ <= 45
2021
static WireType toWireType(const nl::json& obj) {
2122
// as string
2223
const auto str = obj.dump();
2324
const auto jstr = val(str.c_str());
2425
const auto js_obj = val::global("JSON").call<val>("parse", jstr);
2526
return ValBinding::toWireType(js_obj);
2627
}
28+
#else
29+
template<typename ReturnPolicy = void>
30+
static WireType toWireType(const nl::json& obj, rvp::default_tag) {
31+
// as string
32+
const auto str = obj.dump();
33+
const auto jstr = val(str.c_str());
34+
const auto js_obj = val::global("JSON").call<val>("parse", jstr);
35+
return ValBinding::toWireType(js_obj, rvp::default_tag{});
36+
}
37+
#endif
2738

28-
static nl::json fromWireType(WireType value) {
39+
template<typename ReturnPolicy = void>
40+
static nl::json fromWireType(WireType value ) {
2941
// first as emscripten::val
3042
const auto js_obj = ValBinding::fromWireType(value);
3143
// then as string

0 commit comments

Comments
 (0)