JSFiddle - React, Tailwind, and code Playground

by anup1986

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.4.2/umd/react.production.min.js"></script>

JavaScript

class JsonParser extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      formattedJson: '',
    };
  }

	toCamelCase(key, value) {
    if (value && typeof value === 'object') {
      for (var k in value) {
        if (/^[A-Z]/.test(k) && Object.hasOwnProperty.call(value, k)) {
          value[k.charAt(0).toLowerCase() + k.substring(1)] = value[k];
          delete value[k];
        }
      }
    }
    return value;
  }

  //var parsed = JSON.parse(myjson, toCamelCase);

  render() {
    return (
    <pre> { JSON.stringify(this.state.formattedJson, null, 2) } </pre>
    );
  }
}

ReactDOM.render( <
  JsonParser / > ,
  document.getElementById('container')
);