Javascript

This page is under construction.

The Javascript RJson library can be used to:

Including The Code

Using Node / NPM

Install really-relaxed-json from NPM https://www.npmjs.com/package/really-relaxed-json

npm install --save really-relaxed-json
var parser = require('really-relaxed-json').createParser();
var parserFactory = require('really-relaxed-json').createParserFactory();
var PrettyPrinter = require('really-relaxed-json').PrettyPrinter;

Using Standard HTML

Include these files in your <head>

<script src="web/kotlin.js" type="text/javascript"></script>
<script src="web/output-min.js" type="text/javascript"></script>
<script>
    var parser = output.tv.twelvetone.rjson.RJsonParserFactory.Companion.getDefault().createParser();
    const PrettyPrinter = output.tv.twelvetone.rjson.PrettyPrinter;
</script>

Parsing Json

// Call the parse method
var jsonValue = parser.stringToValue('[milk eggs beer {amount:5.44 tax:.99} ]';
var jsonString = parser.stringToJson('[milk eggs beer {amount:5.44 tax:.99} ]';

Pretty Printing

You can pretty print a Json or RJson document by setting the PrettyPrinter options.

Create An Options Object

Customize the options.

    var opts = new PrettyPrinter.Options();
    opts.useQuotes = true;
    opts.useArrayCommas = true;
    opts.useObjectCommas = true;
    opts.objectItemNewline = true;
    opts.arrayItemNewline = true;

Or use one of the presets.

    var opts
    opts = PrettyPrinter.Options.JsonCompact
    opts = PrettyPrinter.Options.JsonPretty
    opts = PrettyPrinter.Options.RJsonCompact
    opts = PrettyPrinter.Options.RJsonPretty

Create A PrettyPrinter

    var prettyPrinter = new PrettyPrinter(opts);
    var prettyString = prettyPrinter.valueToString(json);


This site is StackEditPro enabled.