Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a javascript var like

var data = google.visualization.arrayToDataTable([
      ['Year', 'Sales', 'Expenses'],
      ['2004',  1000,      400],
      ['2005',  1170,      460],
      ['2006',  660,       1120],
      ['2007',  1030,      540]
    ]);

and i want to pass it to a textarea, i try to get as

JSON.stringfy(data, null, '\t');

but i got some ugly text ...

"{\"cols\":[{\"id\":\"\",\"label\":\"Year\",\"pattern\":\"\",\"type\":\"string\"},{\"id\":\"\",\"label\":\"Sales\",\"pattern\":\"\",\"type\":\"number\"},{\"id\":\"\",\"label\":\"Expenses\",\"pattern\":\"\",\"type\":\"number\"}],\"rows\":[{\"c\":[{\"v\":\"2004\",\"f\":null},{\"v\":1000,\"f\":null},{\"v\":400,\"f\":null}]},{\"c\":[{\"v\":\"2005\",\"f\":null},{\"v\":1170,\"f\":null},{\"v\":460,\"f\":null}]},{\"c\":[{\"v\":\"2006\",\"f\":null},{\"v\":660,\"f\":null},{\"v\":1120,\"f\":null}]},{\"c\":[{\"v\":\"2007\",\"f\":null},{\"v\":1030,\"f\":null},{\"v\":540,\"f\":null}]}],\"p\":null}"

im trying to get something like this...

['Year', 'Sales', 'Expenses'],
  ['2004',  1000,      400],
  ['2005',  1170,      460],
  ['2006',  660,       1120],
  ['2007',  1030,      540]

this is google chart code example. How can i get it? if i can....

share|improve this question
    
What do you want the textarea to contain? –  Jonas Berlin Feb 24 '13 at 19:13
    
['Year', 'Sales', 'Expenses'], ['2004', 1000, 400], ['2005', 1170, 460], ['2006', 660, 1120], ['2007', 1030, 540] –  user1977936 Feb 24 '13 at 19:17
    
Is your point perhaps to edit the data in the textarea and then update the display whenever the textarea changes? –  Jonas Berlin Feb 24 '13 at 19:23
    
perhaps yes, if possible –  user1977936 Feb 24 '13 at 19:27
    
isn´t JSON.stringfy(data) what you are looking for ? –  john Smith Feb 24 '13 at 20:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.