Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

[![npm](https://img.shields.io/npm/v/react-json-view.svg)](https://www.npmjs.com/package/react-json-view) [![npm](https://img.shields.io/npm/l/react-json-view.svg)](https://github.com/mac-s-g/react-json-view/blob/master/LISCENSE) [![Build Status](https://travis-ci.org/mac-s-g/react-json-view.svg)](https://travis-ci.org/mac-s-g/react-json-view) [![Coverage Status](https://coveralls.io/repos/github/mac-s-g/react-json-view/badge.svg?branch=master)](https://coveralls.io/github/mac-s-g/react-json-view?branch=master)

# react-json-view
# react-extreme-json-view
This is a fork of RJV.
RJV is a React component for displaying and editing javascript **arrays** and **JSON objects**.

This component provides a responsive interface for displaying arrays or JSON in a web browser. NPM offers a distribution of the source that's transpiled to ES5; so you can include this component with *any web-based javascript application*.
Expand All @@ -13,7 +14,7 @@ This component provides a responsive interface for displaying arrays or JSON in
### Implementation Example
```js
// import the react-json-view component
import ReactJson from 'react-json-view'
import ReactJson from 'react-extreme-json-view'

// use the component in your app!
<ReactJson src={my_json_object} />
Expand Down Expand Up @@ -60,6 +61,7 @@ Name|Type|Default|Description
`onSelect`|`(select)=>{}`|`false`|When a function is passed in, clicking a value triggers the `onSelect` method to be called.
`sortKeys`|`boolean`|`false`|set to true to sort object keys
`quotesOnKeys`|`boolean`|`true`|set to false to remove quotes from keys (eg. `"name":` vs. `name:`)
`quotesOnValues`|`boolean`|`true`|set to false to remove quotes from Values (eg. `[key]: "value"` vs. `[key]: value`)
`validationMessage`|`string`|"Validation Error"|Custom message for validation failures to `onEdit`, `onAdd`, or `onDelete` callbacks
`displayArrayKey`|`boolean`|`true`|When set to `true`, the index of the elements prefix values

Expand Down
6 changes: 6 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ export interface ReactJsonViewProps {
* Default: true
*/
quotesOnKeys?: boolean;
/**
* set to false to remove quotes from Values (eg. [key]: "value" vs. [key]: value)
*
* Default: true
*/
quotesOnValues?: boolean;
/**
* When a callback function is passed in, edit functionality is enabled.
* The callback is invoked before edits are completed. Returning false
Expand Down
24 changes: 22 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-json-view",
"description": "Interactive react component for displaying javascript arrays and JSON objects.",
"name": "react-extreme-json-view",
"description": "Interactive react component for displaying javascript arrays and JSON objects. forked from react-json-view",
"version": "1.21.3",
"main": "dist/main.js",
"dependencies": {
Expand Down Expand Up @@ -68,7 +68,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mac-s-g/react-json-view.git"
"url": "https://github.com/galr52/react-json-view.git"
},
"keywords": [
"array-viewer",
Expand All @@ -95,9 +95,9 @@
"license": "MIT",
"author": "Mac Gainor",
"bugs": {
"url": "https://github.com/mac-s-g/react-json-view/issues"
"url": "https://github.com/galr52/react-json-view/issues"
},
"homepage": "https://github.com/mac-s-g/react-json-view",
"homepage": "https://github.com/galr52/react-json-view",
"directories": {
"docs": "docs",
"test": "test"
Expand Down
11 changes: 8 additions & 3 deletions src/js/components/DataTypes/String.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export default class extends React.PureComponent {
const type_name = 'string';
const { collapsed } = this.state;
const { props } = this;
const { collapseStringsAfterLength, theme } = props;
const {
collapseStringsAfterLength,
theme,
quotesOnValues = true
} = props;
let { value } = props;
let collapsible = toType(collapseStringsAfterLength) === 'integer';
let style = { style: { cursor: 'default' } };
Expand All @@ -57,7 +61,6 @@ export default class extends React.PureComponent {
);
}
}

return (
<div {...Theme(theme, 'string')}>
<DataTypeLabel type_name={type_name} {...props} />
Expand All @@ -66,7 +69,9 @@ export default class extends React.PureComponent {
{...style}
onClick={this.toggleCollapsed}
>
"{value}"
{quotesOnValues ? '"' : ''}
{value}
{quotesOnValues ? '"' : ''}
</span>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ReactJsonView extends React.PureComponent {
shouldCollapse: false,
sortKeys: false,
quotesOnKeys: true,
quotesOnValues: true,
groupArraysAfterLength: 100,
indentWidth: 4,
enableClipboard: true,
Expand Down
17 changes: 17 additions & 0 deletions test/tests/js/components/DataTypes/String-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,21 @@ describe("<JsonString />", function() {
.text()
).to.equal('"123456789"')
})

it("remove quotes from string value", function() {
const props = {
value: "123456789",
quotesOnValues: false,
rjvId: 1,
displayDataTypes: false,
theme: "rjv-default"
}
const component = shallow(<JsonString {...props} />)
expect(
component
.render()
.find(".string-value")
.text()
).to.equal('123456789')
})
})