diff --git a/dist/index.es.js b/dist/index.es.js
index a5522c4..3aebaad 100644
--- a/dist/index.es.js
+++ b/dist/index.es.js
@@ -295,7 +295,7 @@ var JSONViewer = function (_Component) {
value: function arrayToTable(obj) {
var _this4 = this;
- if (util_3(obj) === 'Array' && obj.length === ZERO) {
+ if (util_3(obj) === 'Array' && obj.length === 0) {
return '[ ]';
} else {
return React.createElement(
@@ -307,7 +307,7 @@ var JSONViewer = function (_Component) {
util_1(obj, function (v, key) {
return React.createElement(
'tr',
- _this4.props.trProps,
+ _extends({ key: key }, _this4.props.trProps),
React.createElement(
'td',
_extends({}, _this4.props.tdProps, { style: _this4.constructor.styles.td }),
diff --git a/dist/index.es.js.map b/dist/index.es.js.map
index b0b31bc..8882b6c 100644
--- a/dist/index.es.js.map
+++ b/dist/index.es.js.map
@@ -1 +1 @@
-{"version":3,"file":"index.es.js","sources":["../src/util.js","../src/ValueViewer.js","../src/index.js"],"sourcesContent":["/**\n * Created by narendrasisodiya on 28/10/16.\n */\n\nvar ONE = 1;\nvar loopObject = function loopObject(obj, cb, sorted) {\n var keys = Object.keys(obj);\n if (sorted === true) {\n keys.sort();\n }\n return keys.map(function(key) {\n return cb(obj[key], key);\n });\n};\nvar getSortedKeyString = function getSortedKeyString(obj) {\n return Object.keys(obj)\n .sort()\n .join(',');\n};\nvar getType = function(val) {\n return Object.prototype.toString.call(val).replace(/^\\[object\\s(.*)\\]$/, '$1');\n};\nvar getFirstEle = function getFirstEle(obj) {\n return obj[Object.keys(obj)[0]];\n};\n\nvar allValuesSameInArray = function(arr) {\n for (var i = 1; i < arr.length; i++) {\n if (arr[i] !== arr[0]) {\n return false;\n }\n }\n return true;\n};\n\nvar checkIfArrayIsAOB = function checkIfArrayIsAOB(obj) {\n if (getType(obj) === 'Array' && obj.length > ONE && getType(getFirstEle(obj)) === 'Object') {\n var test = loopObject(obj, function(row) {\n if (getType(row) === 'Object') {\n return getSortedKeyString(row);\n } else {\n return '';\n }\n });\n if (test.length > ONE && test[0].length > ONE) {\n return allValuesSameInArray(test);\n } else {\n return false;\n }\n } else {\n return false;\n }\n};\nvar checkIfObjectIsOOB = function checkIfObjectIsOOB(obj) {\n if (getType(obj) === 'Object' && Object.keys(obj).length > ONE && getType(getFirstEle(obj)) === 'Object') {\n var test = loopObject(obj, function(row) {\n if (getType(row) === 'Object') {\n return getSortedKeyString(row);\n } else {\n return '';\n }\n });\n if (test.length > ONE && test[0].length > ONE) {\n return allValuesSameInArray(test);\n } else {\n return false;\n }\n } else {\n return false;\n }\n};\n\nmodule.exports = {\n loopObject,\n getSortedKeyString,\n getType,\n getFirstEle,\n allValuesSameInArray,\n checkIfArrayIsAOB,\n checkIfObjectIsOOB,\n};\n","import React, { Component } from 'react';\n\nimport PropTypes from 'prop-types';\nimport { getType } from './util';\n\nclass ValueViewer extends Component {\n constructor(props, context) {\n super(props, context);\n }\n\n r() {\n switch (getType(this.props.value)) {\n case 'String':\n return {`\"${this.props.value}\"`};\n case 'Boolean':\n return {`${this.props.value}`};\n case 'Number':\n return {`${this.props.value}`};\n case 'Undefined':\n return {'undefined'};\n case 'Null':\n return {'null'};\n case 'Date':\n return {`${JSON.stringify(this.props.value)}`};\n default:\n return {`${this.props.value}`};\n }\n }\n\n render() {\n return {this.r()};\n }\n}\nValueViewer.propTypes = {\n value: PropTypes.any,\n};\nValueViewer.defaultProps = {};\nexport default ValueViewer;\n","import React, { Component } from 'react';\nimport { checkIfArrayIsAOB, checkIfObjectIsOOB, getFirstEle, getType, loopObject } from './util';\n\nimport PropTypes from 'prop-types';\nimport ValueViewer from './ValueViewer';\n\nexport default class JSONViewer extends Component {\n static propTypes = {\n json: PropTypes.any.isRequired,\n tableProps: PropTypes.object,\n trProps: PropTypes.object,\n tdProps: PropTypes.object,\n thProps: PropTypes.object,\n tbodyProps: PropTypes.object,\n theadProps: PropTypes.object,\n };\n\n static styles = {\n td: {\n border: '1px solid #cccccc',\n textAlign: 'left',\n margin: 0,\n padding: '6px 13px',\n },\n th: {\n border: '1px solid #cccccc',\n textAlign: 'left',\n margin: 0,\n padding: '6px 13px',\n fontWeight: 'bold',\n },\n };\n static defaultProps = {};\n\n renderHeaderByKeys(keys, addExtra) {\n return (\n \n \n {(() => {\n if (addExtra === 'addExtra') {\n return (\n \n \n | \n );\n }\n })()}\n {keys.map((key, i) => {\n return (\n \n {key}\n | \n );\n })}\n
\n \n );\n }\n\n objToTable(obj) {\n if (JSON.stringify(obj) === '{}') {\n return '{ }';\n } else {\n return (\n
\n {this.renderHeaderByKeys(Object.keys(obj))}\n \n \n {loopObject(obj, (v, key) => {\n return this.renderTd(v, key);\n })}\n
\n \n
\n );\n }\n }\n\n arrayToTable(obj) {\n if (getType(obj) === 'Array' && obj.length === ZERO) {\n return '[ ]';\n } else {\n return (\n \n \n {loopObject(obj, (v, key) => {\n return (\n \n {`${key}`} | \n {this.renderTd(v, key)}\n
\n );\n })}\n \n
\n );\n }\n }\n\n oobToTable(aob) {\n return (\n \n {this.renderHeaderByKeys(Object.keys(getFirstEle(aob)), 'addExtra')}\n \n {loopObject(aob, (row, j) => {\n return (\n \n \n \n | \n {loopObject(getFirstEle(aob), (val, key) => {\n return this.renderTd(row[key], key);\n })}\n
\n );\n })}\n \n
\n );\n }\n renderTd(guess, index) {\n return (\n \n {this.decideAndRender(guess)}\n | \n );\n }\n decideAndRender(guess) {\n if (getType(guess) === 'Array') {\n if (checkIfArrayIsAOB(guess)) {\n return this.aobToTable(guess);\n } else {\n return this.arrayToTable(guess);\n }\n }\n if (getType(guess) === 'Object') {\n if (checkIfObjectIsOOB(guess)) {\n return this.oobToTable(guess);\n } else {\n return this.objToTable(guess);\n }\n } else {\n return ;\n }\n }\n\n aobToTable(aob) {\n return (\n \n {this.renderHeaderByKeys(Object.keys(getFirstEle(aob)))}\n \n {loopObject(aob, (row, j) => {\n return (\n \n {loopObject(getFirstEle(aob), (val, key) => {\n return this.renderTd(row[key], key);\n })}\n
\n );\n })}\n \n
\n );\n }\n\n render() {\n return {this.decideAndRender(this.props.json)}
;\n }\n}\n"],"names":["ONE","loopObject","obj","cb","sorted","keys","Object","sort","map","key","getSortedKeyString","join","getType","val","prototype","toString","call","replace","getFirstEle","allValuesSameInArray","arr","i","length","checkIfArrayIsAOB","test","row","checkIfObjectIsOOB","module","ValueViewer","props","context","value","color","JSON","stringify","r","Component","propTypes","PropTypes","any","defaultProps","JSONViewer","addExtra","theadProps","trProps","thProps","constructor","styles","td","tdProps","tableProps","renderHeaderByKeys","v","renderTd","ZERO","aob","j","guess","index","decideAndRender","aobToTable","arrayToTable","oobToTable","objToTable","tbodyProps","json","isRequired","object"],"mappings":";;;AAAA;;;;AAIA,IAAIA,MAAM,CAAV;AACA,IAAIC,aAAa,SAASA,UAAT,CAAoBC,GAApB,EAAyBC,EAAzB,EAA6BC,MAA7B,EAAqC;MAChDC,OAAOC,OAAOD,IAAP,CAAYH,GAAZ,CAAX;MACIE,WAAW,IAAf,EAAqB;SACdG,IAAL;;SAEKF,KAAKG,GAAL,CAAS,UAASC,GAAT,EAAc;WACrBN,GAAGD,IAAIO,GAAJ,CAAH,EAAaA,GAAb,CAAP;GADK,CAAP;CALF;AASA,IAAIC,qBAAqB,SAASA,kBAAT,CAA4BR,GAA5B,EAAiC;SACjDI,OAAOD,IAAP,CAAYH,GAAZ,EACJK,IADI,GAEJI,IAFI,CAEC,GAFD,CAAP;CADF;AAKA,IAAIC,UAAU,SAAVA,OAAU,CAASC,GAAT,EAAc;SACnBP,OAAOQ,SAAP,CAAiBC,QAAjB,CAA0BC,IAA1B,CAA+BH,GAA/B,EAAoCI,OAApC,CAA4C,oBAA5C,EAAkE,IAAlE,CAAP;CADF;AAGA,IAAIC,cAAc,SAASA,WAAT,CAAqBhB,GAArB,EAA0B;SACnCA,IAAII,OAAOD,IAAP,CAAYH,GAAZ,EAAiB,CAAjB,CAAJ,CAAP;CADF;;AAIA,IAAIiB,uBAAuB,SAAvBA,oBAAuB,CAASC,GAAT,EAAc;OAClC,IAAIC,IAAI,CAAb,EAAgBA,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AwB7C,OAAOD,IAAP,CAAYa,OAAYqC,GAAZ,CAAZ,CAAxB,CADH;;;eAEkB1B,KAAL,CAAWmC,UAAtB;iBACcT,GAAX,EAAgB,UAAC9B,GAAD,EAAM+B,CAAN,EAAY;mBAEzB;;2BAAQ,OAAK3B,KAAL,CAAWe,OAAnB,IAA4B,KAAKY,CAAjC;qBACctC,OAAYqC,GAAZ,CAAX,EAA6B,UAAC1C,GAAD,EAAMJ,GAAN,EAAc;uBACnC,OAAK4C,QAAL,CAAc5B,IAAIhB,GAAJ,CAAd,EAAwBA,GAAxB,CAAP;eADD;aAFL;WADD;;OAJP;;;;6BAkBO;aACA;;;aAAWkD,eAAL,CAAqB,KAAK9B,KAAL,CAAWoC,IAAhC;OAAb;;;;EAhKoC7B;;AAAnBK,WACZJ,YAAY;QACXC,UAAUC,GAAV,CAAc2B,UADH;cAEL5B,UAAU6B,MAFL;WAGR7B,UAAU6B,MAHF;WAIR7B,UAAU6B,MAJF;WAKR7B,UAAU6B,MALF;cAML7B,UAAU6B,MANL;cAOL7B,UAAU6B;;AARL1B,WAWZM,SAAS;MACV;YACM,mBADN;eAES,MAFT;YAGM,CAHN;aAIO;GALG;MAOV;YACM,mBADN;eAES,MAFT;YAGM,CAHN;aAIO,UAJP;gBAKU;;;AAvBGN,WA0BZD,eAAe;;;;"}
\ No newline at end of file
+{"version":3,"file":"index.es.js","sources":["../src/util.js","../src/ValueViewer.js","../src/index.js"],"sourcesContent":["/**\n * Created by narendrasisodiya on 28/10/16.\n */\n\nvar ONE = 1;\nvar loopObject = function loopObject(obj, cb, sorted) {\n var keys = Object.keys(obj);\n if (sorted === true) {\n keys.sort();\n }\n return keys.map(function(key) {\n return cb(obj[key], key);\n });\n};\nvar getSortedKeyString = function getSortedKeyString(obj) {\n return Object.keys(obj)\n .sort()\n .join(',');\n};\nvar getType = function(val) {\n return Object.prototype.toString.call(val).replace(/^\\[object\\s(.*)\\]$/, '$1');\n};\nvar getFirstEle = function getFirstEle(obj) {\n return obj[Object.keys(obj)[0]];\n};\n\nvar allValuesSameInArray = function(arr) {\n for (var i = 1; i < arr.length; i++) {\n if (arr[i] !== arr[0]) {\n return false;\n }\n }\n return true;\n};\n\nvar checkIfArrayIsAOB = function checkIfArrayIsAOB(obj) {\n if (getType(obj) === 'Array' && obj.length > ONE && getType(getFirstEle(obj)) === 'Object') {\n var test = loopObject(obj, function(row) {\n if (getType(row) === 'Object') {\n return getSortedKeyString(row);\n } else {\n return '';\n }\n });\n if (test.length > ONE && test[0].length > ONE) {\n return allValuesSameInArray(test);\n } else {\n return false;\n }\n } else {\n return false;\n }\n};\nvar checkIfObjectIsOOB = function checkIfObjectIsOOB(obj) {\n if (getType(obj) === 'Object' && Object.keys(obj).length > ONE && getType(getFirstEle(obj)) === 'Object') {\n var test = loopObject(obj, function(row) {\n if (getType(row) === 'Object') {\n return getSortedKeyString(row);\n } else {\n return '';\n }\n });\n if (test.length > ONE && test[0].length > ONE) {\n return allValuesSameInArray(test);\n } else {\n return false;\n }\n } else {\n return false;\n }\n};\n\nmodule.exports = {\n loopObject,\n getSortedKeyString,\n getType,\n getFirstEle,\n allValuesSameInArray,\n checkIfArrayIsAOB,\n checkIfObjectIsOOB,\n};\n","import React, { Component } from 'react';\n\nimport PropTypes from 'prop-types';\nimport { getType } from './util';\n\nclass ValueViewer extends Component {\n constructor(props, context) {\n super(props, context);\n }\n\n r() {\n switch (getType(this.props.value)) {\n case 'String':\n return {`\"${this.props.value}\"`};\n case 'Boolean':\n return {`${this.props.value}`};\n case 'Number':\n return {`${this.props.value}`};\n case 'Undefined':\n return {'undefined'};\n case 'Null':\n return {'null'};\n case 'Date':\n return {`${JSON.stringify(this.props.value)}`};\n default:\n return {`${this.props.value}`};\n }\n }\n\n render() {\n return {this.r()};\n }\n}\nValueViewer.propTypes = {\n value: PropTypes.any,\n};\nValueViewer.defaultProps = {};\nexport default ValueViewer;\n","import React, { Component } from 'react';\nimport { checkIfArrayIsAOB, checkIfObjectIsOOB, getFirstEle, getType, loopObject } from './util';\n\nimport PropTypes from 'prop-types';\nimport ValueViewer from './ValueViewer';\n\nexport default class JSONViewer extends Component {\n static propTypes = {\n json: PropTypes.any.isRequired,\n tableProps: PropTypes.object,\n trProps: PropTypes.object,\n tdProps: PropTypes.object,\n thProps: PropTypes.object,\n tbodyProps: PropTypes.object,\n theadProps: PropTypes.object,\n };\n\n static styles = {\n td: {\n border: '1px solid #cccccc',\n textAlign: 'left',\n margin: 0,\n padding: '6px 13px',\n },\n th: {\n border: '1px solid #cccccc',\n textAlign: 'left',\n margin: 0,\n padding: '6px 13px',\n fontWeight: 'bold',\n },\n };\n static defaultProps = {};\n\n renderHeaderByKeys(keys, addExtra) {\n return (\n \n \n {(() => {\n if (addExtra === 'addExtra') {\n return (\n \n \n | \n );\n }\n })()}\n {keys.map((key, i) => {\n return (\n \n {key}\n | \n );\n })}\n
\n \n );\n }\n\n objToTable(obj) {\n if (JSON.stringify(obj) === '{}') {\n return '{ }';\n } else {\n return (\n \n {this.renderHeaderByKeys(Object.keys(obj))}\n \n \n {loopObject(obj, (v, key) => {\n return this.renderTd(v, key);\n })}\n
\n \n
\n );\n }\n }\n\n arrayToTable(obj) {\n if (getType(obj) === 'Array' && obj.length === 0) {\n return '[ ]';\n } else {\n return (\n \n \n {loopObject(obj, (v, key) => {\n return (\n \n {`${key}`} | \n {this.renderTd(v, key)}\n
\n );\n })}\n \n
\n );\n }\n }\n\n oobToTable(aob) {\n return (\n \n {this.renderHeaderByKeys(Object.keys(getFirstEle(aob)), 'addExtra')}\n \n {loopObject(aob, (row, j) => {\n return (\n \n \n \n | \n {loopObject(getFirstEle(aob), (val, key) => {\n return this.renderTd(row[key], key);\n })}\n
\n );\n })}\n \n
\n );\n }\n renderTd(guess, index) {\n return (\n \n {this.decideAndRender(guess)}\n | \n );\n }\n decideAndRender(guess) {\n if (getType(guess) === 'Array') {\n if (checkIfArrayIsAOB(guess)) {\n return this.aobToTable(guess);\n } else {\n return this.arrayToTable(guess);\n }\n }\n if (getType(guess) === 'Object') {\n if (checkIfObjectIsOOB(guess)) {\n return this.oobToTable(guess);\n } else {\n return this.objToTable(guess);\n }\n } else {\n return ;\n }\n }\n\n aobToTable(aob) {\n return (\n \n {this.renderHeaderByKeys(Object.keys(getFirstEle(aob)))}\n \n {loopObject(aob, (row, j) => {\n return (\n \n {loopObject(getFirstEle(aob), (val, key) => {\n return this.renderTd(row[key], key);\n })}\n
\n );\n })}\n \n
\n );\n }\n\n render() {\n return {this.decideAndRender(this.props.json)}
;\n }\n}\n"],"names":["ONE","loopObject","obj","cb","sorted","keys","Object","sort","map","key","getSortedKeyString","join","getType","val","prototype","toString","call","replace","getFirstEle","allValuesSameInArray","arr","i","length","checkIfArrayIsAOB","test","row","checkIfObjectIsOOB","module","ValueViewer","props","context","value","color","JSON","stringify","r","Component","propTypes","PropTypes","any","defaultProps","JSONViewer","addExtra","theadProps","trProps","thProps","constructor","styles","td","tdProps","tableProps","renderHeaderByKeys","v","renderTd","aob","j","guess","index","decideAndRender","aobToTable","arrayToTable","oobToTable","objToTable","tbodyProps","json","isRequired","object"],"mappings":";;;AAAA;;;;AAIA,IAAIA,MAAM,CAAV;AACA,IAAIC,aAAa,SAASA,UAAT,CAAoBC,GAApB,EAAyBC,EAAzB,EAA6BC,MAA7B,EAAqC;MAChDC,OAAOC,OAAOD,IAAP,CAAYH,GAAZ,CAAX;MACIE,WAAW,IAAf,EAAqB;SACdG,IAAL;;SAEKF,KAAKG,GAAL,CAAS,UAASC,GAAT,EAAc;WACrBN,GAAGD,IAAIO,GAAJ,CAAH,EAAaA,GAAb,CAAP;GADK,CAAP;CALF;AASA,IAAIC,qBAAqB,SAASA,kBAAT,CAA4BR,GAA5B,EAAiC;SACjDI,OAAOD,IAAP,CAAYH,GAAZ,EACJK,IADI,GAEJI,IAFI,CAEC,GAFD,CAAP;CADF;AAKA,IAAIC,UAAU,SAAVA,OAAU,CAASC,GAAT,EAAc;SACnBP,OAAOQ,SAAP,CAAiBC,QAAjB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/index.js
@@ -300,7 +300,7 @@ var JSONViewer = function (_Component) {
value: function arrayToTable(obj) {
var _this4 = this;
- if (util_3(obj) === 'Array' && obj.length === ZERO) {
+ if (util_3(obj) === 'Array' && obj.length === 0) {
return '[ ]';
} else {
return React__default.createElement(
@@ -312,7 +312,7 @@ var JSONViewer = function (_Component) {
util_1(obj, function (v, key) {
return React__default.createElement(
'tr',
- _this4.props.trProps,
+ _extends({ key: key }, _this4.props.trProps),
React__default.createElement(
'td',
_extends({}, _this4.props.tdProps, { style: _this4.constructor.styles.td }),
diff --git a/dist/index.js.map b/dist/index.js.map
index 505ddf3..c7a9e27 100644
--- a/dist/index.js.map
+++ b/dist/index.js.map
@@ -1 +1 @@
-{"version":3,"file":"index.js","sources":["../src/util.js","../src/ValueViewer.js","../src/index.js"],"sourcesContent":["/**\n * Created by narendrasisodiya on 28/10/16.\n */\n\nvar ONE = 1;\nvar loopObject = function loopObject(obj, cb, sorted) {\n var keys = Object.keys(obj);\n if (sorted === true) {\n keys.sort();\n }\n return keys.map(function(key) {\n return cb(obj[key], key);\n });\n};\nvar getSortedKeyString = function getSortedKeyString(obj) {\n return Object.keys(obj)\n .sort()\n .join(',');\n};\nvar getType = function(val) {\n return Object.prototype.toString.call(val).replace(/^\\[object\\s(.*)\\]$/, '$1');\n};\nvar getFirstEle = function getFirstEle(obj) {\n return obj[Object.keys(obj)[0]];\n};\n\nvar allValuesSameInArray = function(arr) {\n for (var i = 1; i < arr.length; i++) {\n if (arr[i] !== arr[0]) {\n return false;\n }\n }\n return true;\n};\n\nvar checkIfArrayIsAOB = function checkIfArrayIsAOB(obj) {\n if (getType(obj) === 'Array' && obj.length > ONE && getType(getFirstEle(obj)) === 'Object') {\n var test = loopObject(obj, function(row) {\n if (getType(row) === 'Object') {\n return getSortedKeyString(row);\n } else {\n return '';\n }\n });\n if (test.length > ONE && test[0].length > ONE) {\n return allValuesSameInArray(test);\n } else {\n return false;\n }\n } else {\n return false;\n }\n};\nvar checkIfObjectIsOOB = function checkIfObjectIsOOB(obj) {\n if (getType(obj) === 'Object' && Object.keys(obj).length > ONE && getType(getFirstEle(obj)) === 'Object') {\n var test = loopObject(obj, function(row) {\n if (getType(row) === 'Object') {\n return getSortedKeyString(row);\n } else {\n return '';\n }\n });\n if (test.length > ONE && test[0].length > ONE) {\n return allValuesSameInArray(test);\n } else {\n return false;\n }\n } else {\n return false;\n }\n};\n\nmodule.exports = {\n loopObject,\n getSortedKeyString,\n getType,\n getFirstEle,\n allValuesSameInArray,\n checkIfArrayIsAOB,\n checkIfObjectIsOOB,\n};\n","import React, { Component } from 'react';\n\nimport PropTypes from 'prop-types';\nimport { getType } from './util';\n\nclass ValueViewer extends Component {\n constructor(props, context) {\n super(props, context);\n }\n\n r() {\n switch (getType(this.props.value)) {\n case 'String':\n return {`\"${this.props.value}\"`};\n case 'Boolean':\n return {`${this.props.value}`};\n case 'Number':\n return {`${this.props.value}`};\n case 'Undefined':\n return {'undefined'};\n case 'Null':\n return {'null'};\n case 'Date':\n return {`${JSON.stringify(this.props.value)}`};\n default:\n return {`${this.props.value}`};\n }\n }\n\n render() {\n return {this.r()};\n }\n}\nValueViewer.propTypes = {\n value: PropTypes.any,\n};\nValueViewer.defaultProps = {};\nexport default ValueViewer;\n","import React, { Component } from 'react';\nimport { checkIfArrayIsAOB, checkIfObjectIsOOB, getFirstEle, getType, loopObject } from './util';\n\nimport PropTypes from 'prop-types';\nimport ValueViewer from './ValueViewer';\n\nexport default class JSONViewer extends Component {\n static propTypes = {\n json: PropTypes.any.isRequired,\n tableProps: PropTypes.object,\n trProps: PropTypes.object,\n tdProps: PropTypes.object,\n thProps: PropTypes.object,\n tbodyProps: PropTypes.object,\n theadProps: PropTypes.object,\n };\n\n static styles = {\n td: {\n border: '1px solid #cccccc',\n textAlign: 'left',\n margin: 0,\n padding: '6px 13px',\n },\n th: {\n border: '1px solid #cccccc',\n textAlign: 'left',\n margin: 0,\n padding: '6px 13px',\n fontWeight: 'bold',\n },\n };\n static defaultProps = {};\n\n renderHeaderByKeys(keys, addExtra) {\n return (\n \n \n {(() => {\n if (addExtra === 'addExtra') {\n return (\n \n \n | \n );\n }\n })()}\n {keys.map((key, i) => {\n return (\n \n {key}\n | \n );\n })}\n
\n \n );\n }\n\n objToTable(obj) {\n if (JSON.stringify(obj) === '{}') {\n return '{ }';\n } else {\n return (\n \n {this.renderHeaderByKeys(Object.keys(obj))}\n \n \n {loopObject(obj, (v, key) => {\n return this.renderTd(v, key);\n })}\n
\n \n
\n );\n }\n }\n\n arrayToTable(obj) {\n if (getType(obj) === 'Array' && obj.length === ZERO) {\n return '[ ]';\n } else {\n return (\n \n \n {loopObject(obj, (v, key) => {\n return (\n \n {`${key}`} | \n {this.renderTd(v, key)}\n
\n );\n })}\n \n
\n );\n }\n }\n\n oobToTable(aob) {\n return (\n \n {this.renderHeaderByKeys(Object.keys(getFirstEle(aob)), 'addExtra')}\n \n {loopObject(aob, (row, j) => {\n return (\n \n \n \n | \n {loopObject(getFirstEle(aob), (val, key) => {\n return this.renderTd(row[key], key);\n })}\n
\n );\n })}\n \n
\n );\n }\n renderTd(guess, index) {\n return (\n \n {this.decideAndRender(guess)}\n | \n );\n }\n decideAndRender(guess) {\n if (getType(guess) === 'Array') {\n if (checkIfArrayIsAOB(guess)) {\n return this.aobToTable(guess);\n } else {\n return this.arrayToTable(guess);\n }\n }\n if (getType(guess) === 'Object') {\n if (checkIfObjectIsOOB(guess)) {\n return this.oobToTable(guess);\n } else {\n return this.objToTable(guess);\n }\n } else {\n return ;\n }\n }\n\n aobToTable(aob) {\n return (\n \n {this.renderHeaderByKeys(Object.keys(getFirstEle(aob)))}\n \n {loopObject(aob, (row, j) => {\n return (\n \n {loopObject(getFirstEle(aob), (val, key) => {\n return this.renderTd(row[key], key);\n })}\n
\n );\n })}\n \n
\n );\n }\n\n render() {\n return {this.decideAndRender(this.props.json)}
;\n }\n}\n"],"names":["ONE","loopObject","obj","cb","sorted","keys","Object","sort","map","key","getSortedKeyString","join","getType","val","prototype","toString","call","replace","getFirstEle","allValuesSameInArray","arr","i","length","checkIfArrayIsAOB","test","row","checkIfObjectIsOOB","module","ValueViewer","props","context","value","React","color","JSON","stringify","r","Component","propTypes","PropTypes","any","defaultProps","JSONViewer","addExtra","theadProps","trProps","thProps","constructor","styles","td","tdProps","tableProps","renderHeaderByKeys","v","renderTd","ZERO","aob","j","guess","index","decideAndRender","aobToTable","arrayToTable","oobToTable","objToTable","tbodyProps","json","isRequired","object"],"mappings":";;;;;;;;AAAA;;;;AAIA,IAAIA,MAAM,CAAV;AACA,IAAIC,aAAa,SAASA,UAAT,CAAoBC,GAApB,EAAyBC,EAAzB,EAA6BC,MAA7B,EAAqC;MAChDC,OAAOC,OAAOD,IAAP,CAAYH,GAAZ,CAAX;MACIE,WAAW,IAAf,EAAqB;SACdG,IAAL;;SAEKF,KAAKG,GAAL,CAAS,UAASC,GAAT,EAAc;WACrBN,GAAGD,IAAIO,GAAJ,CAAH,EAAaA,GAAb,CAAP;GADK,CAAP;CALF;AASA,IAAIC,qBAAqB,SAASA,kBAAT,CAA4BR,GAA5B,EAAiC;SACjDI,OAAOD,IAAP,CAAYH,GAAZ,EACJK,IADI,GAEJI,IAFI,CAEC,GAFD,CAAP;CADF;AAKA,IAAIC,UAAU,SAAVA,OAAU,CAASC,GAAT,EAAc;SACnBP,OAAOQ,SAAP,CAAiBC,QAAjB,CAA0BC,IAA1B,CAA+BH,GAA/B,EAAoCI,OAApC,CAA4C,oBAA5C,EAAkE,IAAlE,CAAP;CADF;AAGA,IAAIC,cAAc,SAASA,WAAT,CAAqBhB,GAArB,EAA0B;SACnCA,IAAII,OAAOD,IAAP,CAAYH,GAAZ,EAAiB,CAAjB,CAAJ,CAAP;CADF;;AAIA,IAAIiB,uBAAuB,SAAvBA,oBAAuB,CAASC,GAAT,EAAc;OAClC,IAAIC,IAAI,CAAb,EAAgBA,IAAID,IAAIE,MAAxB,EAAgCD,GAAhC,EAAqC;QAC/BD,IAAIC,CAAJ,MAAWD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AAZ,CAAZ,CAAxB,CADH;;;eAEkB3B,KAAL,CAAWoC,UAAtB;iBACcT,GAAX,EAAgB,UAAC/B,GAAD,EAAMgC,CAAN,EAAY;mBAEzBzB;;2BAAQ,OAAKH,KAAL,CAAWgB,OAAnB,IAA4B,KAAKY,CAAjC;qBACcvC,OAAYsC,GAAZ,CAAX,EAA6B,UAAC3C,GAAD,EAAMJ,GAAN,EAAc;uBACnC,OAAK6C,QAAL,CAAc7B,IAAIhB,GAAJ,CAAd,EAAwBA,GAAxB,CAAP;eADD;aAFL;WADD;;OAJP;;;;6BAkBO;aACAuB;;;aAAW4B,eAAL,CAAqB,KAAK/B,KAAL,CAAWqC,IAAhC;OAAb;;;;EAhKoC7B;;AAAnBK,WACZJ,YAAY;QACXC,UAAUC,GAAV,CAAc2B,UADH;cAEL5B,UAAU6B,MAFL;WAGR7B,UAAU6B,MAHF;WAIR7B,UAAU6B,MAJF;WAKR7B,UAAU6B,MALF;cAML7B,UAAU6B,MANL;cAOL7B,UAAU6B;;AARL1B,WAWZM,SAAS;MACV;YACM,mBADN;eAES,MAFT;YAGM,CAHN;aAIO;GALG;MAOV;YACM,mBADN;eAES,MAFT;YAGM,CAHN;aAIO,UAJP;gBAKU;;;AAvBGN,WA0BZD,eAAe;;;;"}
\ No newline at end of file
+{"version":3,"file":"index.js","sources":["../src/util.js","../src/ValueViewer.js","../src/index.js"],"sourcesContent":["/**\n * Created by narendrasisodiya on 28/10/16.\n */\n\nvar ONE = 1;\nvar loopObject = function loopObject(obj, cb, sorted) {\n var keys = Object.keys(obj);\n if (sorted === true) {\n keys.sort();\n }\n return keys.map(function(key) {\n return cb(obj[key], key);\n });\n};\nvar getSortedKeyString = function getSortedKeyString(obj) {\n return Object.keys(obj)\n .sort()\n .join(',');\n};\nvar getType = function(val) {\n return Object.prototype.toString.call(val).replace(/^\\[object\\s(.*)\\]$/, '$1');\n};\nvar getFirstEle = function getFirstEle(obj) {\n return obj[Object.keys(obj)[0]];\n};\n\nvar allValuesSameInArray = function(arr) {\n for (var i = 1; i < arr.length; i++) {\n if (arr[i] !== arr[0]) {\n return false;\n }\n }\n return true;\n};\n\nvar checkIfArrayIsAOB = function checkIfArrayIsAOB(obj) {\n if (getType(obj) === 'Array' && obj.length > ONE && getType(getFirstEle(obj)) === 'Object') {\n var test = loopObject(obj, function(row) {\n if (getType(row) === 'Object') {\n return getSortedKeyString(row);\n } else {\n return '';\n }\n });\n if (test.length > ONE && test[0].length > ONE) {\n return allValuesSameInArray(test);\n } else {\n return false;\n }\n } else {\n return false;\n }\n};\nvar checkIfObjectIsOOB = function checkIfObjectIsOOB(obj) {\n if (getType(obj) === 'Object' && Object.keys(obj).length > ONE && getType(getFirstEle(obj)) === 'Object') {\n var test = loopObject(obj, function(row) {\n if (getType(row) === 'Object') {\n return getSortedKeyString(row);\n } else {\n return '';\n }\n });\n if (test.length > ONE && test[0].length > ONE) {\n return allValuesSameInArray(test);\n } else {\n return false;\n }\n } else {\n return false;\n }\n};\n\nmodule.exports = {\n loopObject,\n getSortedKeyString,\n getType,\n getFirstEle,\n allValuesSameInArray,\n checkIfArrayIsAOB,\n checkIfObjectIsOOB,\n};\n","import React, { Component } from 'react';\n\nimport PropTypes from 'prop-types';\nimport { getType } from './util';\n\nclass ValueViewer extends Component {\n constructor(props, context) {\n super(props, context);\n }\n\n r() {\n switch (getType(this.props.value)) {\n case 'String':\n return {`\"${this.props.value}\"`};\n case 'Boolean':\n return {`${this.props.value}`};\n case 'Number':\n return {`${this.props.value}`};\n case 'Undefined':\n return {'undefined'};\n case 'Null':\n return {'null'};\n case 'Date':\n return {`${JSON.stringify(this.props.value)}`};\n default:\n return {`${this.props.value}`};\n }\n }\n\n render() {\n return {this.r()};\n }\n}\nValueViewer.propTypes = {\n value: PropTypes.any,\n};\nValueViewer.defaultProps = {};\nexport default ValueViewer;\n","import React, { Component } from 'react';\nimport { checkIfArrayIsAOB, checkIfObjectIsOOB, getFirstEle, getType, loopObject } from './util';\n\nimport PropTypes from 'prop-types';\nimport ValueViewer from './ValueViewer';\n\nexport default class JSONViewer extends Component {\n static propTypes = {\n json: PropTypes.any.isRequired,\n tableProps: PropTypes.object,\n trProps: PropTypes.object,\n tdProps: PropTypes.object,\n thProps: PropTypes.object,\n tbodyProps: PropTypes.object,\n theadProps: PropTypes.object,\n };\n\n static styles = {\n td: {\n border: '1px solid #cccccc',\n textAlign: 'left',\n margin: 0,\n padding: '6px 13px',\n },\n th: {\n border: '1px solid #cccccc',\n textAlign: 'left',\n margin: 0,\n padding: '6px 13px',\n fontWeight: 'bold',\n },\n };\n static defaultProps = {};\n\n renderHeaderByKeys(keys, addExtra) {\n return (\n \n \n {(() => {\n if (addExtra === 'addExtra') {\n return (\n \n \n | \n );\n }\n })()}\n {keys.map((key, i) => {\n return (\n \n {key}\n | \n );\n })}\n
\n \n );\n }\n\n objToTable(obj) {\n if (JSON.stringify(obj) === '{}') {\n return '{ }';\n } else {\n return (\n \n {this.renderHeaderByKeys(Object.keys(obj))}\n \n \n {loopObject(obj, (v, key) => {\n return this.renderTd(v, key);\n })}\n
\n \n
\n );\n }\n }\n\n arrayToTable(obj) {\n if (getType(obj) === 'Array' && obj.length === 0) {\n return '[ ]';\n } else {\n return (\n \n \n {loopObject(obj, (v, key) => {\n return (\n \n {`${key}`} | \n {this.renderTd(v, key)}\n
\n );\n })}\n \n
\n );\n }\n }\n\n oobToTable(aob) {\n return (\n \n {this.renderHeaderByKeys(Object.keys(getFirstEle(aob)), 'addExtra')}\n \n {loopObject(aob, (row, j) => {\n return (\n \n \n \n | \n {loopObject(getFirstEle(aob), (val, key) => {\n return this.renderTd(row[key], key);\n })}\n
\n );\n })}\n \n
\n );\n }\n renderTd(guess, index) {\n return (\n \n {this.decideAndRender(guess)}\n | \n );\n }\n decideAndRender(guess) {\n if (getType(guess) === 'Array') {\n if (checkIfArrayIsAOB(guess)) {\n return this.aobToTable(guess);\n } else {\n return this.arrayToTable(guess);\n }\n }\n if (getType(guess) === 'Object') {\n if (checkIfObjectIsOOB(guess)) {\n return this.oobToTable(guess);\n } else {\n return this.objToTable(guess);\n }\n } else {\n return ;\n }\n }\n\n aobToTable(aob) {\n return (\n \n {this.renderHeaderByKeys(Object.keys(getFirstEle(aob)))}\n \n {loopObject(aob, (row, j) => {\n return (\n \n {loopObject(getFirstEle(aob), (val, key) => {\n return this.renderTd(row[key], key);\n })}\n
\n );\n })}\n \n
\n );\n }\n\n render() {\n return {this.decideAndRender(this.props.json)}
;\n }\n}\n"],"names":["ONE","loopObject","obj","cb","sorted","keys","Object","sort","map","key","getSortedKeyString","join","getType","val","prototype","toString","call","replace","getFirstEle","allValuesSameInArray","arr","i","length","checkIfArrayIsAOB","test","row","checkIfObjectIsOOB","module","ValueViewer","props","context","value","React","color","JSON","stringify","r","Component","propTypes","PropTypes","any","defaultProps","JSONViewer","addExtra","theadProps","trProps","thProps","constructor","styles","td","tdProps","tableProps","renderHeaderByKeys","v","renderTd","aob","j","guess","index","decideAndRender","aobToTable","arrayToTable","oobToTable","objToTable","tbodyProps","json","isRequired","object"],"mappings":";;;;;;;;AAAA;;;;AAIA,IAAIA,MAAM,CAAV;AACA,IAAIC,aAAa,SAASA,UAAT,CAAoBC,GAApB,EAAyBC,EAAzB,EAA6BC,MAA7B,EAAqC;MAChDC,OAAOC,OAAOD,IAAP,CAAYH,GAAZ,CAAX;MACIE,WAAW,IAAf,EAAqB;SACdG,IAAL;;SAEKF,KAAKG,GAAL,CAAS,UAASC,GAAT,EAAc;WACrBN,GAAGD,IAAIO,GAAJ,CAAH,EAAaA,GAAb,CAAP;GADK,CAAP;CALF;AASA,IAAIC,qBAAqB,SAASA,kBAAT,CAA4BR,GAA5B,EAAiC;SACjDI,OAAOD,IAAP,CAAYH,GAAZ,EACJK,IADI,GAEJI,IAFI,CAEC,GAFD,CAAP;CADF;AAKA,IAAIC,UAAU,SAAVA,OAAU,CAASC,GAAT,EAAc;SACnBP,OAAOQ,SAAP,CAAiBC,QAAjB,CAA0BC,IAA1B,CAA+BH,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- a/example/package-lock.json
+++ b/example/package-lock.json
@@ -8420,6 +8420,14 @@
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-4.0.1.tgz",
"integrity": "sha512-xXUbDAZkU08aAkjtUvldqbvI04ogv+a1XdHxvYuHPYKIVk/42BIOD0zSKTHAWV4+gDy3yGm283z2072rA2gdtw=="
},
+ "react-gist": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/react-gist/-/react-gist-1.2.1.tgz",
+ "integrity": "sha512-2zxOrdxipjW2KrPTy7FJsYzzOsK84ReufIEnSKypq5pjRKurYzJTtQD4vffWviWWyJiqTniox7kDG+/yEtCs/g==",
+ "requires": {
+ "prop-types": "^15.6.0"
+ }
+ },
"react-is": {
"version": "16.8.6",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.8.6.tgz",
diff --git a/example/package.json b/example/package.json
index 9b22718..c2379f8 100644
--- a/example/package.json
+++ b/example/package.json
@@ -8,8 +8,9 @@
"prop-types": "^15.6.2",
"react": "^16.4.1",
"react-dom": "^16.4.1",
- "react-scripts": "^1.1.4",
- "react-json-viewer": "file:.."
+ "react-gist": "^1.2.1",
+ "react-json-viewer": "file:..",
+ "react-scripts": "^1.1.4"
},
"scripts": {
"start": "react-scripts start",
diff --git a/example/src/App.js b/example/src/App.js
index bae4380..3d97e45 100644
--- a/example/src/App.js
+++ b/example/src/App.js
@@ -1,23 +1,61 @@
import React, { Component } from 'react';
+import Gist from 'react-gist';
import JSONViewer from 'react-json-viewer';
+var testData = {
+ name: 'Narendra',
+ age: 32,
+ place: {
+ name: 'Delhi',
+ pin: '110017',
+ },
+ likes: ['Apple', 'Banana', 'Mango'],
+ test: {
+ userData: undefined,
+ loginData: null,
+ },
+ todos: [
+ {
+ task: 'Write Book',
+ done: false,
+ },
+ {
+ task: 'Learn React',
+ done: true,
+ },
+ {
+ task: 'Buy Mobile',
+ done: false,
+ },
+ ],
+ dateWiseData: {
+ '2016-02-14': {
+ availableRooms: 10,
+ soldRooms: 20,
+ },
+ '2016-02-15': {
+ availableRooms: 15,
+ soldRooms: 15,
+ },
+ '2016-02-16': {
+ availableRooms: 5,
+ soldRooms: 25,
+ },
+ '2016-02-17': {
+ availableRooms: 0,
+ soldRooms: 30,
+ },
+ },
+};
export default class App extends Component {
render() {
return (
-
+
React JSON Viewer Demo
+
+
Following Test JSON Data is rendered above into a Tabular Format using react-json-viewer
+
);
}
diff --git a/src/index.js b/src/index.js
index e09f3ea..3d93569 100644
--- a/src/index.js
+++ b/src/index.js
@@ -77,7 +77,7 @@ export default class JSONViewer extends Component {
}
arrayToTable(obj) {
- if (getType(obj) === 'Array' && obj.length === ZERO) {
+ if (getType(obj) === 'Array' && obj.length === 0) {
return '[ ]';
} else {
return (
@@ -85,7 +85,7 @@ export default class JSONViewer extends Component {
{loopObject(obj, (v, key) => {
return (
-
+
{`${key}`} |
{this.renderTd(v, key)}