Skip to content

nerdlabs/parse-attributes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published