Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8927331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:12:12+00:00 2026-06-15T08:12:12+00:00

I have a string var myString = [‘Item’, ‘Count’],[‘iPad’,2],[‘Android’,1]; I need to convert it

  • 0

I have a string

 var myString = "['Item', 'Count'],['iPad',2],['Android',1]";

I need to convert it into an array where:

myArray[0][0] = 'Item';
myArray[0][1] = 'Count';
myArray[1][0] = 'iPad';
myArray[1][1] = 2;

etc…

The string can vary in length but will always be in the format above. I have tried splitting and splicing and any other “ing” I can think of but I can’t get it.

Can anyone help please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:12:14+00:00Added an answer on June 15, 2026 at 8:12 am

    If the string is certain to be secure, the simplest would be to concatenat [ and ] to the beginning and end, and then eval it.

    var arr = eval("[" + myString + "]");
    

    If you wanted greater safety, use double quotes for your strings, and use JSON.parse() in the same way.

    var myString = '["Item", "Count"],["iPad",2],["Android",1]';
    
    var arr = JSON.parse("[" + myString + "]");
    

    This will limit you to supported JSON data types, but given your example string, it’ll work fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to current string taken from <div id=someif array-data=2012-03-01:1,2012-03-11:1,2012-03-21:1></div> var mystring={2012-03-01:1,2012-03-11:1,2012-03-21:1} and need
I have got below string values in a variable. var mystring = '{img_src:/english/images/spa.jpg, img_title:Enjoy
I have a string looks like: var myString= '{key1:value1, key2:value2, key3:value3}'; What I want
I have the following string in JavaScript var mystring = abcdef(p,q); check(x,y); cef(m,n); I
I have the following code snippet Procedure TFrm.Retrieve(mystring : string); var bs : TStream;
I have a dynamically generated large string which I am splitting. var myString=val1, val,
I have a string MyString like this: var MyString = 32,43,545,34,23,; I'd like to
I have a string var (path) that represents a path: printfn Please enter a
I have this string: var someString = 23/03/2012; and want to replace all the
If I have the string: var myStr = foo_0_bar_0; and I guess we should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.