diff --git a/dev-server/src/index.js b/dev-server/src/index.js index 169a2501..cab67b7e 100644 --- a/dev-server/src/index.js +++ b/dev-server/src/index.js @@ -181,6 +181,7 @@ function getExampleJson1() { return { string: 'this is a test string', integer: 42, + bigint: BigInt('123456789012345678901234567890'), empty_array: [], empty_object: {}, array: [1, 2, 3, 'test'], diff --git a/package-lock.json b/package-lock.json index 9589552f..5c224251 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-json-view", - "version": "1.21.1", + "version": "1.21.3", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -4073,12 +4073,27 @@ "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", "dev": true }, + "bignumber.js": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.1.tgz", + "integrity": "sha512-IdZR9mh6ahOBv/hYGiXyVuyCetmGJhtYkqLBpTStdhEGjegpPlUawydyaF3pbIOFynJTpllEs+NP+CS9jKFLjA==" + }, "binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "dev": true }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dev": true, + "optional": true, + "requires": { + "file-uri-to-path": "1.0.0" + } + }, "block-stream": { "version": "0.0.9", "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", @@ -7839,6 +7854,13 @@ } } }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "dev": true, + "optional": true + }, "filesize": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/filesize/-/filesize-6.1.0.tgz", @@ -12141,6 +12163,14 @@ "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", "dev": true }, + "json-bigint": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", + "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", + "requires": { + "bignumber.js": "^9.0.0" + } + }, "json-parse-better-errors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", @@ -16438,6 +16468,7 @@ "dev": true, "optional": true, "requires": { + "bindings": "^1.5.0", "nan": "^2.12.1" } } @@ -20337,6 +20368,7 @@ "dev": true, "optional": true, "requires": { + "bindings": "^1.5.0", "nan": "^2.12.1" } }, @@ -21140,6 +21172,7 @@ "dev": true, "optional": true, "requires": { + "bindings": "^1.5.0", "nan": "^2.12.1" } }, diff --git a/package.json b/package.json index 36d66aad..ba8cc61f 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "dist/main.js", "dependencies": { "flux": "^4.0.1", + "json-bigint": "^1.0.0", "react-base16-styling": "^0.6.0", "react-lifecycles-compat": "^3.0.4", "react-textarea-autosize": "^8.3.2" diff --git a/src/js/components/CopyToClipboard.js b/src/js/components/CopyToClipboard.js index 62ea78df..9b8faeef 100644 --- a/src/js/components/CopyToClipboard.js +++ b/src/js/components/CopyToClipboard.js @@ -1,4 +1,5 @@ import React from 'react'; +import JSONBig from 'json-bigint'; import { toType } from './../helpers/util'; @@ -29,7 +30,7 @@ export default class extends React.PureComponent { const container = document.createElement('textarea'); const { clickCallback, src, namespace } = this.props; - container.innerHTML = JSON.stringify( + container.innerHTML = JSONBig.stringify( this.clipboardValue(src), null, ' ' diff --git a/src/js/components/DataTypes/BigInt.js b/src/js/components/DataTypes/BigInt.js new file mode 100644 index 00000000..d0df6d68 --- /dev/null +++ b/src/js/components/DataTypes/BigInt.js @@ -0,0 +1,18 @@ +import React from 'react'; +import DataTypeLabel from './DataTypeLabel'; + +//theme +import Theme from './../../themes/getStyle'; + +export default class extends React.PureComponent { + render() { + const type_name = 'bigint'; + const { props } = this; + return ( +