-1

How do I take data in a json file given like this:

Ticker,Quandl Code,Name
STI,GOOG/NYSE_STI,SunTrust Banks 
AAPL,GOOG/NASDAQ_AAPL,Apple Inc

and turn it into an array like this:

var stocks = [
    ["STI,GOOG/NYSE_STI,SunTrust Banks"],
    ["AAPL,GOOG/NASDAQ_AAPL,Apple Inc"]
];
1
  • That is not a JSON format that you are working with. It appears to be CSV Commented Mar 9, 2014 at 7:23

2 Answers 2

4

Your input is in CSV, not JSON. The following question has a function that converts CSV for an array:

Javascript code to parse CSV data

Sign up to request clarification or add additional context in comments.

Comments

0

you can do this :

var myarray = [];
var myJSON = "";
for (var i = 0; i < 10; i++) {

    var item = {
        "value": i,
        "label": i
    };
    myarray.push(item);
}
myJSON = JSON.stringify({myarray: myarray});

alert(myJSON);

1 Comment

Insert this code in console fire fox and run then you can see result.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.