Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including really-relaxed-json with all npm packages installed. Try it out:

//import {toJs, toJson, toRJson, prettyPrint, Options, createParser} from 'really-relaxed-json' // Use import if you can. const rrj = require('really-relaxed-json'); const toJson = rrj.toJson; const toRJson = rrj.toRJson; const toJs = rrj.toJs; const prettyPrint = rrj.prettyPrint; const Options = rrj.Options; const createParser = rrj.createParser; const results = []; // Converting RJSON to JSON results['compact-json'] = toJson('[ one two three {foo:bar} ]'); results['pretty-json'] = toJson('[ one two three {foo:bar} ]', false); // Converting JSON to RJSON results['compact-rjson'] = toRJson('[ "one", "two", "three", {"foo": "bar"} ]'); // Converting JSON to Javascript results['compact-js'] = toJs('[ "one", "two", "three", {"foo": "bar"} ]'); // Parsing const parser = createParser(); const jsonValue = parser.stringToValue('[ one two three {foo:bar} ]'); // Now use or inspect the value object... results['jsonValueString'] = jsonValue.toString(); // JsonValue.toString() will print compact JSON results['stringToJson'] = parser.stringToJson('[ one two three {foo:bar} ]'); // Formatting / Converting results['prettyFromValue'] = prettyPrint(Options.JsonPretty, jsonValue); results['prettyFromString'] = prettyPrint(Options.JsonPretty, '[ one two three {foo:bar} ]'); results;

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

really-relaxed-json v0.3.2

A really relaxed version of JSON parsing and formatting that allows for optional commas, quotes, and comments.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free