From 66f0d7bd0d17156478c665586a8e07d8a005de84 Mon Sep 17 00:00:00 2001 From: Joe Farro Date: Mon, 25 Dec 2017 01:06:50 -0500 Subject: [PATCH] Only JSON.parse JSON strings in tags/logs values Signed-off-by: Joe Farro --- .../SpanDetail/KeyValuesTable.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/TracePage/TraceTimelineViewer/SpanDetail/KeyValuesTable.js b/src/components/TracePage/TraceTimelineViewer/SpanDetail/KeyValuesTable.js index 304776616b..c7c10d8219 100644 --- a/src/components/TracePage/TraceTimelineViewer/SpanDetail/KeyValuesTable.js +++ b/src/components/TracePage/TraceTimelineViewer/SpanDetail/KeyValuesTable.js @@ -19,12 +19,15 @@ import jsonMarkup from 'json-markup'; import './KeyValuesTable.css'; -function parseOrPass(value) { +function parseIfJson(value) { try { - return JSON.parse(value); - } catch (_) { - return value; - } + const data = JSON.parse(value); + if (data && typeof data === 'object') { + return data; + } + // eslint-disable-next-line no-empty + } catch (_) {} + return value; } type KeyValuesTableProps = { @@ -40,7 +43,7 @@ export default function KeyValuesTable(props: KeyValuesTableProps) { {data.map((row, i) => { const jsonTable = ( // eslint-disable-next-line react/no-danger -
+
); return ( // `i` is necessary in the key because row.key can repeat