From fb0afbc452f70871d0a9f3cbb5ffad960abccec6 Mon Sep 17 00:00:00 2001 From: Daniel Gonzalez Date: Wed, 29 Sep 2021 20:56:58 -0400 Subject: [PATCH] feat(json): Automatically parse JSON --- src/explorer/details.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/explorer/details.js b/src/explorer/details.js index 983f859..4fe48b8 100644 --- a/src/explorer/details.js +++ b/src/explorer/details.js @@ -69,7 +69,7 @@ class Details extends React.Component { - Signature : {entryData.signature}

- - Data : {entryData.data} + - Data : {_this.formatData(entryData.data)}

)} @@ -119,6 +119,18 @@ class Details extends React.Component { handleClose () { _this.props.onClose() } + + formatData (data) { + try { + const parsed = JSON.parse(data) + const str = JSON.stringify(parsed, null, 2) + + return str + } catch (error) { + console.warn('error in formatData', error) + return data + } + } } Details.propTypes = { entry: PropTypes.object,