str2obj
v1.0.0
Published
str2obj is a function that converts a nice literal string into an object.
Downloads
3
Readme
JavaScript/NodeJS str2obj v1.0.0
What is this?
str2obj is a function that converts a nice literal string into an object.
Demo online
http://jsfiddle.net/yeikos/jwad5/
Example
<html>
<head>
<title>str2obj</title>
<script type="text/javascript" src="https://raw.github.com/yeikos/js.str2obj/master/str2obj.js"></script>
<script type="text/javascript">
console.log(str2obj('name(password), min(6), error(false)', true));
/*
{
name: 'password',
min: 6,
error: false
}
*/
console.log(str2obj('words(one, two, three) width(800, 600)'));
/*
{
words: ['one, 'two', 'three'],
width: [800, 600]
}
*/
</script>
</head>
<body>See the console log.</body>
</html>