Skip to content

albin3/js-json-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

editor-json-parser

this repo support parse standard json and something like this:

Build Status NPM Version NPM Downloads

support: AMD / CommonJs / script tag

{
  "foo": 'bar'
}

{
  foo: 'bar'
}

{
  'foo': "bar"
}

it also support comments and comma at last line

{
  // comment
  foo: 'bar'    // comment
}

{
  foo: 'bar',
  foo1: 'bar1',
}

commonjs usage

npm install --save editor-json-parser

let parser = require('editor-json-parser');
let result = parser.parse("{foo: 'bar'}");
// result: {foo: 'bar'}
result = parser.parse("{'foo': 'bar'}");
// result: {foo: 'bar'}
result = parser.parse('{"foo": "bar"}');
// result: {foo: 'bar'}

script tag

<script src="./dist/json_parser.js"><script/>

var jsonParser = window.json_parser;

AMD support

...