jquery - How to extract from JSON to create a new JSON files -


i have json data coming database dynamically, see below:

[["15","0.027","0.137","0.353","0.044","0.111","0.024","2013-07-30 17:45:06"],["17","0.027","0.137","0.353","0.044","0.111","0.024","2013-07-30 17:50:14"],["19","0.017","0.137","0.353","0.044","0.111","0.024","2013-07-30 17:55:35"],["21","0.017","0.137","0.353","0.044","0.111","0.024","2013-07-30 18:00:34"],["23","0.017","0.137","0.353","0.044","0.111","0.024","2013-07-30 18:05:10"],["25","0.017","0.137","0.353","0.044","0.111","0.024","2013-07-30 18:10:07"] , on.. 

so structure follows [time1, time2, time3, time4, time5, time5, time7, timestamp]

what need achieve end 7 new jsons have structure follows:

json1 = [time1,timestamp] json2 = [time2,timestamp] json3 = [time3,timestamp] json4 = [time4,timestamp] , on.. 

i need implement jqplot can please? thank you

check (you can find ready-to-play jsfiddle here):

// creates new array items array item  // given index , last item (timestamp). function timenfromitems(items, index) {     return [items[index], items[items.length - 1]]; }  // loop on each time index, from: // [time1, time2, time3, time4, time5, time6, time7, timestamp] // ...the following printed out: // time1, timestamp // time2, timestamp // [...] // time7, timestamp function timesfromitems(items) {     numberoftimes = 7;     result = "";     (var = 0; < numberoftimes; ++i) {         result += timenfromitems(items, i) + "\n";     }     return result; }  sample = [     ["15", "0.027", "0.137", "0.353", "0.044", "0.111", "0.024", "2013-07-30 17:45:06"],     ["17", "0.027", "0.137", "0.353", "0.044", "0.111", "0.024", "2013-07-30 17:50:14"],     ["19", "0.017", "0.137", "0.353", "0.044", "0.111", "0.024", "2013-07-30 17:55:35"],     ["21", "0.017", "0.137", "0.353", "0.044", "0.111", "0.024", "2013-07-30 18:00:34"],     ["23", "0.017", "0.137", "0.353", "0.044", "0.111", "0.024", "2013-07-30 18:05:10"],     ["25", "0.017", "0.137", "0.353", "0.044", "0.111", "0.024", "2013-07-30 18:10:07"] ];  alert(timesfromitems(sample[0])); 

the first function gets given pair "row", second 1 loops on pairs.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -