From 19e8bfdb37d99fe70015d83c4e6a3e4203e8c1ed Mon Sep 17 00:00:00 2001 From: Thomas Nordquist Date: Thu, 16 Apr 2020 10:53:50 +0200 Subject: [PATCH] Fix chart where properties contain periods Fixes #281 --- backend/src/JsonAstParser.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/src/JsonAstParser.ts b/backend/src/JsonAstParser.ts index ee3863c..dc69157 100644 --- a/backend/src/JsonAstParser.ts +++ b/backend/src/JsonAstParser.ts @@ -70,9 +70,11 @@ function jsonToPropertyPaths(ast: JsonAst, previousPath: Array = []): Ar } else if (ast.type === 'Array') { children = ast.children.map((value, idx) => jsonToPropertyPaths(value, previousPath.slice().concat([String(idx)]))) } else if (ast.type === 'Object') { - children = ast.children.map((property) => - jsonToPropertyPaths(property.value, previousPath.slice().concat([property.key.value])) - ) + children = ast.children.map((property) => { + const path = property.key.value.replace('.', '\\.') + + return jsonToPropertyPaths(property.value, previousPath.slice().concat([path])) + }) } return children.reduce((a, b) => a.concat(b), [])