0.0.3 • Published 10 years ago
jsonx-js v0.0.3
JSONx-js
JSONxis a superset ofJSON, meaning a validJSONstring is automatically a validJSONxstring.JSONxis not intended to replaceJSON, instead, it is intended to be translated toJSON.JSONx-jsis the Javascript binding ofJSONx. It helps to translate aJSONxstring to aJSONstring.
Installation
npm install jsonx-js
Examples
{
// keys are not necessary to be quoted
name: "jsonx",
/* This is also a comment. */
url: "http://jsonx.org",
/*
Here is some more comments
which span across multi lines.
*/
"languages-bindings": ["Javascript", "Golang",],
/*
Tailing comma is not a problem.
Multiline text also works.
*/
description: `Multiline text is translated into an array
of strings. JSONx makes JSON easier to use for
configuration files.`,
}The JSONx above should produce the following JSON:
{
"name": "jsonx",
"url": "http://jsonx.org",
"languages-bindings": [
"Javascript",
"Golang"
],
"description": [
"Multiline text is translated into an array",
"of strings. JSONx makes JSON easier to use for",
"configuration files."
]
}Code in Node.js
var jsonx = require('jsonx-js');
var jsonxString = '...';
var jsonString = jsonx.toJSON(jsonxString);
console.log(jsonString);Code in browsers
<script src="path/to/jsonx.js"></script>
<script>
var jsonxString = '...';
var jsonString = jsonx.toJSON(jsonxString);
console.log(jsonString);
</script>