mirror of
https://github.com/fullstack-cash/explorer.fullstack.cash.git
synced 2026-09-21 16:52:05 -07:00
Merge pull request #3 from Permissionless-Software-Foundation/dh-parse-json
feat(json): Automatically parse JSON
This commit is contained in:
+13
-1
@@ -69,7 +69,7 @@ class Details extends React.Component {
|
||||
- <b>Signature : </b> {entryData.signature}
|
||||
</p>
|
||||
<p>
|
||||
- <b>Data : </b> {entryData.data}
|
||||
- <b>Data : </b> {_this.formatData(entryData.data)}
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user