Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

How to convert a multi-dimensional array into an eval() compatible string.

So I have a webpage where a user can dynamically create their own multi-dimensional array. I need to be able to convert this array into a string for saving that'll work with eval() to recreate that same array.

Example:
var myarray=["A", ["1","2"],"B","C"]; (representing the user's dynamically created array if it was written out)
Needed Output: ["A", ["1","2"],"B","C"]

Thanks!
0
GrrWolfie
Asked:
GrrWolfie
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
var myarray=["A", ["1","2"],"B","C"];
var myarrayStr = JSON.stringify(myarray);

test page : http://jsfiddle.net/4fbra/

0
 
GrrWolfieAuthor Commented:
Works perfect! Thankyou! :) :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now