From 2bd242a1649fbca6f3c97f1495458673c4242afd Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Wed, 26 Aug 2020 18:21:37 -0400 Subject: [PATCH] jsonParse now validates for array as root JSONs fixes #1097 --- helpers/jsonParse.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/helpers/jsonParse.js b/helpers/jsonParse.js index 23ceb4de3..3250f93a8 100644 --- a/helpers/jsonParse.js +++ b/helpers/jsonParse.js @@ -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