Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yosuke-furukawa/json5x
JSON5 for JSX
https://github.com/yosuke-furukawa/json5x
Last synced: about 1 month ago
JSON representation
JSON5 for JSX
- Host: GitHub
- URL: https://github.com/yosuke-furukawa/json5x
- Owner: yosuke-furukawa
- Created: 2014-03-13T11:28:18.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T05:11:33.000Z (11 months ago)
- Last Synced: 2024-09-14T18:42:57.513Z (2 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
JSON5 library for JSX
========================[JSON5](http://json5.org/) is really useful library for json.
JSON5 can add comments and last commas are available.Getting Started
===============```shell
$ npm install json5x -S
```usage:
```js
import "json5/json5.jsx";class _Test extends TestCase {
function testParse() : void {
var testData = """
{
foo: 'bar',
while: true,this: 'is a \
multi-line string',// this is an inline comment
here: 'is another', // inline comment/* this is a block comment
that continues on another line */hex: 0xDEADbeef,
half: .5,
delta: +10,
to: Infinity, // and beyond!finally: 'a trailing comma',
oh: [
"we shouldn't forget",
'arrays can have',
'trailing commas too',
],
}
""";
var testJson = JSON5.parse(testData);
this.expect(testJson["foo"]).toBe("bar");
this.expect(testJson["while"]).toBe(true);
this.expect(testJson["this"]).toMatch(/^is a .*/);
this.expect(testJson["this"]).toMatch(/.* multi-line string/);
this.expect(testJson["here"]).toBe("is another");
this.expect(testJson["hex"]).toBe(0xDEADbeef);
this.expect(testJson["half"]).toBe(0.5);
this.expect(testJson["delta"]).toBe(10);
this.expect(testJson["to"]).toBe(Infinity);
this.expect(testJson["finally"]).toBe("a trailing comma");
this.expect(testJson["oh"]).toEqual([ "we shouldn't forget", "arrays can have", "trailing commas too"]);
}
```LICENSE
=========MIT