Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

str2obj is a function that converts a nice literal string into an object.

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.md

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>
Something went wrong with that request. Please try again.