Skip to main content
Deno 2 is finally here 🎉️
Learn more

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
 *      }
 *  }
 */