- LocalScope scope(exec->globalData());
- LiteralParser jsonParser(exec, source.characters(), source.length(), LiteralParser::StrictJSON);
- JSValue unfiltered = jsonParser.tryLiteralParse();
- if (!unfiltered)
- return throwVMError(exec, createSyntaxError(exec, "Unable to parse JSON string"));
+ JSValue unfiltered;
+ LocalScope scope(exec->vm());
+ if (source.is8Bit()) {
+ LiteralParser<LChar> jsonParser(exec, source.characters8(), source.length(), StrictJSON);
+ unfiltered = jsonParser.tryLiteralParse();
+ if (!unfiltered)
+ return throwVMError(exec, createSyntaxError(exec, jsonParser.getErrorMessage()));
+ } else {
+ LiteralParser<UChar> jsonParser(exec, source.characters16(), source.length(), StrictJSON);
+ unfiltered = jsonParser.tryLiteralParse();
+ if (!unfiltered)
+ return throwVMError(exec, createSyntaxError(exec, jsonParser.getErrorMessage()));
+ }