mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 21:01:52 +00:00
Fix JSON parsing failure
This commit is contained in:
@@ -249,7 +249,14 @@ unsigned char JSC__JSValue__jsType(JSC__JSValue JSValue0)
|
||||
JSC__JSValue JSC__JSValue__parseJSON(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1)
|
||||
{
|
||||
JSC::JSValue jsValue = JSC::JSValue::decode(JSValue0);
|
||||
return JSC::JSValue::encode(JSC::JSONParse(arg1, jsValue.toWTFString(arg1)));
|
||||
|
||||
JSC::JSValue result = JSC::JSONParse(arg1, jsValue.toWTFString(arg1));
|
||||
|
||||
if (!result) {
|
||||
result = JSC::JSValue(JSC::createSyntaxError(arg1->globalObject(), "Failed to parse JSON"));
|
||||
}
|
||||
|
||||
return JSC::JSValue::encode(result);
|
||||
}
|
||||
|
||||
void JSC__JSGlobalObject__deleteModuleRegistryEntry(JSC__JSGlobalObject* global, ZigString* arg1)
|
||||
|
||||
@@ -2007,6 +2007,13 @@ pub const JSValue = enum(u64) {
|
||||
else => false,
|
||||
};
|
||||
}
|
||||
/// Empty as in "JSValue {}" rather than an empty string
|
||||
pub fn isEmpty(this: JSValue) bool {
|
||||
return switch (@enumToInt(this)) {
|
||||
0 => true,
|
||||
else => false,
|
||||
};
|
||||
}
|
||||
pub fn isBoolean(this: JSValue) bool {
|
||||
return cppFn("isBoolean", .{this});
|
||||
}
|
||||
|
||||
@@ -1708,6 +1708,9 @@ pub const Blob = struct {
|
||||
value: JSC.JSValue,
|
||||
global: *JSGlobalObject,
|
||||
) JSC.JSValue {
|
||||
if (value.isError()) {
|
||||
return JSC.JSPromise.rejectedPromiseValue(global, value);
|
||||
}
|
||||
return JSC.JSPromise.resolvedPromiseValue(global, value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user