Skip to main content

HJSON   Badge License

A parser / stringifier for HJSON.


Import

import HJson from 'https://deno.land/x/hjson/mod.ts'


Parse

import { parse } from 'https://deno.land/x/hjson/mod.ts'

const { log } = console;

const hjson = `{
    some : 3
    variables : [
        with ,
        a
        lot
    ]
    inside : {
        them : 9
    }
}`

log(parse(hjson));


/*
 *  {
 *      some : 3 ,
 *      variables : [ 'with' , 'a' , 'lot' ] ,
 *      inside : { them : 9 }
 *  }
 */


Stringify

import { stringify } from 'https://deno.land/x/hjson/mod.ts'

const { log } = console;

const object = {
    some : 3 ,
    variables : [ 'with' , 'a' , 'lot' ] ,
    inside : { them : 9 }
}

log(stringify(hjson));


/*
 *  { 
 *      some : 3
 *  
 *      variables : [
 *          with
 *          a
 *          lot
 *      ]
 *  
 *      inside : {
 *          them : 9
 *      }
 *  }
 */