Question: I have this string which I want to convert to an array:

```
var test = "{href:'one'},{href:'two'}";

```

So how can I convert this to an array?:

```
var new = [{href:'one'},{href:'two'}];

```

Answer: 
It depends where you got it from..

If possible you should correct it a bit to make it valid JSON syntax (*at least in terms of the quotes*)

```
var test  = '{"href":"one"},{"href":"two"}';
var arr = JSON.parse('[' + test + ']');

```

Notice the `"` around both keys and values.

(*making directly `var test = '[{"href":"one"},{"href":"two"}]';` is even better*)
If you could modify the original string to be valid JSON then you could do this:

```
JSON.parse(test)

```

Valid JSON:

```
var test  = '[{"href":"one"},{"href":"two"}]';

```