jsonParse now validates for array as root JSONs

fixes #1097
This commit is contained in:
Andrew Bastin
2020-08-26 18:21:37 -04:00
parent 4b87684611
commit 2bd242a164

View File

@@ -25,9 +25,16 @@ export default function jsonParse(str) {
start = end = lastEnd = -1
ch()
lex()
const ast = parseObj()
expect("EOF")
return ast
try {
const ast = parseObj()
expect("EOF")
return ast
} catch (e) {
// Try parsing expecting a root array
const ast = parseArr()
expect("EOF")
return ast
}
}
let string