nerdlabs / parse-attributes

Parse attributes from xmlish strings like a boss

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

parse-attributes Build Status Coverage Status

Parse attributes from xmlish strings like a boss

Install

npm install --save parse-attributes

Docs

Test-documentation generated with mocha's "doc" reporter.

Usage

var parseAttributes = require('parse-attributes');
console.log(parseAttributes('foo="bar" bar=baz boo=\'quux\' boolean'));

Outputs:

{
    "foo": "bar",
    "bar": "baz"
    "boo": "quux"
    "boolean": true
}

Things that break

The parser currently is not able to differentiate between escaped quotes and the ending quote. As soon as the same type of quote as the opening quote is found, the parser stops and takes takes everything in-between as value. This breaks valid JSON in attribute values.

About

Parse attributes from xmlish strings like a boss

License:MIT License


Languages

Language:JavaScript 98.9%Language:Shell 1.1%