Convert JSON structure

Posted by Scobal on Stack Overflow See other posts from Stack Overflow or by Scobal
Published on 2010-03-25T10:47:13Z Indexed on 2010/03/25 10:53 UTC
Read the original article Hit count: 421

Filed under:
|
|

I have a set of data in one JSON structure:

[[task1, 10, 99],  
[task2, 10, 99],  
[task3, 10, 99],  
[task1, 11, 99],  
[task2, 11, 99],  
[task3, 11, 99]] 

and need to convert it to another JSON structure:

[{  
  label: "task1",  
  data: [[10, 99], [11, 99]]  
},  
{   
  label: "task2",  
  data: [[10, 99], [11, 99]] 
},  
{  
  label: "task3",  
  data: [[10, 99], [11, 99]]
}]

What's the best way to do this with javascript/java?

© Stack Overflow or respective owner

Related posts about JSON

Related posts about JavaScript