Parse attributes from xmlish strings like a boss
npm install --save parse-attributes
Test-documentation generated with mocha's "doc" reporter.
var parseAttributes = require('parse-attributes');
console.log(parseAttributes('foo="bar" bar=baz boo=\'quux\' boolean'));
Outputs:
{
"foo": "bar",
"bar": "baz"
"boo": "quux"
"boolean": true
}
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.