diff options
Diffstat (limited to 'src/bun.js/bindings/bindings.cpp')
| -rw-r--r-- | src/bun.js/bindings/bindings.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index fe778ce42..d3e718ba7 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -950,6 +950,20 @@ void WebCore__DOMURL__pathname_(WebCore__DOMURL* domURL, ZigString* arg1) *arg1 = Zig::toZigString(pathname); } +extern "C" JSC__JSValue ZigString__toJSONObject(const ZigString* strPtr, JSC::JSGlobalObject* globalObject) +{ + auto str = Zig::toString(*strPtr); + auto throwScope = DECLARE_THROW_SCOPE(globalObject->vm()); + auto scope = DECLARE_CATCH_SCOPE(globalObject->vm()); + JSValue result = JSONParseWithException(globalObject, str); + if (auto* exception = scope.exception()) { + scope.clearException(); + RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(exception->value())); + } + + RELEASE_AND_RETURN(throwScope, JSValue::encode(result)); +} + JSC__JSValue SystemError__toErrorInstance(const SystemError* arg0, JSC__JSGlobalObject* globalObject) { |
