Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 1.1 KB

README.md

File metadata and controls

43 lines (33 loc) · 1.1 KB

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.