hocon-parser

This is a very basic [Hocon](https://github.com/typesafehub/config/blob/master/HOCON.md) parser written in JavaScript.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
hocon-parser
3651.0.16 years ago6 years agoMinified + gzip package size for hocon-parser in KB

Readme

Travis Build Status
HoconJS
This is a very basic Hocon parser written in JavaScript.
It does almost no validation whatsoever but can create an object from most hocon files.
Please feel free to contribute with PRs.
This module is intended to work in the browser and nodejs.
Browser usage :
<script type="text/javascript" src="/node_modules/hocon-parser/hocon.min.js"></script>
<script type="text/javascript">
    var obj = parseHocon(someHoconText);
</script>

NodeJS :
var parseHocon = require('hocon-parser');
var obj = parseHocon(someHoconText);

Scripts

  • Installing : npm install hocon-parser
  • Running tests : npm test
    Building source : npm run release

Example Output

Input Hocon string:
myConfig.cool.numb: 5
myConfig.cool.stuff: {
   x : quotesarebadmmkay
   z : {
     yes: 'no not really'
   }
}
myConfig.cool.stuff { z { no='yes yes really' } }
myConfig.dupe: ${myConfig.cool.stuff.x}
meinarr [2,3, {x:haha}]
meinobj {hocon: issoweirdman}
notherobj : ${meinobj.hocon}

Output object:
{
  "myConfig": {
    "cool": {
      "numb": 5,
      "stuff": {
        "x": "quotesarebadmmkay",
        "z": {
          "yes": "no not really",
          "no": "yes yes really"
        }
      }
    },
    "dupe": "quotesarebadmmkay"
  },
  "meinarr": [2, 3, {
    "x": "haha"
  }],
  "meinobj": {
    "hocon": "issoweirdman"
  },
  "notherobj": "issoweirdman"
}

Features

| Feature | Completion | Example |---------|-------------|--------| | Objects | :whitecheckmark: | myKey { myOtherKey: 'myValue' } | Arrays | :whitecheckmark: | myKey [1,2,3,4] | Comments | :whitecheckmark: | // some comment # some comment | = and : Separators | :whitecheckmark: | myKey='myValue' | Unquoted Strings | :whitecheckmark: | myKey: myString | Multiline Strings (""") | :whitecheckmark: | myKey: """what's happening""" | Path Expressions | :whitecheckmark: | myRoot.myKey.someKey : 4 | Substitutions | :whitecheckmark: | myKey: $(myRoot.myKey) | String Concatenation in Arrays | :whitecheckmark: | myArr: [hello there] | | Objects Merging | :x: | | | Value Concatenation | :x: | | | include | :x: | | |