Search code examples
javascriptarraysjquery-textext

Javascript stringed array into an actual array


Ok. So the title sounds confusing but that's probably the best way to describe it.

I'm using the TextExt jQuery plugin to create a tag list in a form. However the plugin creates an array in a string when submitted. eg. "["this","that","other"]".

How can I convert this to an actual array? ["this","that","other"]

Cue really simple answer I completely overlooked.


Solution

  • Since you are using jQuery you can just pass it through jQuery.parseJSON like this:

    var array = jQuery.parseJSON('["this","that","other"]')