Convert JSON structure

前端 未结 3 1433
-上瘾入骨i
-上瘾入骨i 2021-01-22 13:15

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]] 
         


        
3条回答
  •  太阳男子
    2021-01-22 13:23

    First you need to parse the JSON to get real objects.

    With JavaScript you can just eval() it, or use JSON.parse(). There is a JSON implementation at JSON.org for browsers that don't have this built in.

    For Java (an entirely different language), JSON.org also has an implementation of a JSON parser that you can use.

    Once you've got the objects out of it, you can then just re-arrange until your heart's content, then JSON.stringify() (in JS) to convert back to JSON.

提交回复
热议问题