I have a json string:
arguments[0] = [{"one":"1","two":"1","three":"15","four":"esj","five":null,"six":"2015-10-15 00:00:00","seven":null},
{"one":"1","two":"1","three":"15","four":"esj","five":null,"six":"2015-10-15 00:00:00","seven":null},
{"one":"1","two":"1","three":"15","four":"esj","five":null,"six":"2015-10-15 00:00:00","seven":null, ...}]
and I want to change it to the format like this:
[ '1', '1', '15', 'esj', null, '2015-10-15 00:00:00', null],
[ '1', '1', '15', 'esj', null, '2015-10-15 00:00:00', null],
[ '1', '1', '15', 'esj', null, '2015-10-15 00:00:00', null], etc...
how can I do it in jquery?
EDIT:
Using @Joseph the dreamer's answer I almost made it work, now I'm using:
return ["['"+arg.one+"'", "'"+arg.two+"'", "'"+arg.three+"'", "'"+arg.four+"'", "'"+arg.five+"'", "'"+arg.six+"']"]
and it produces me this:
[1,2,3,4,5,6],[1,2,3,4,5,6], etc
which is fine, but I need to convert it later on to a string. How can I do that?
No jQuery required actually. All you need is map
.
var arr = arguments[0].map(function(arg){
return [arg.one, arg.two, arg.three, arg.four, arg.five, arg.six, arg.seven];
});
Would have gone for Object.keys
to loop through the keys, but order had to be preserved. Plus, I would discourage modifying arguments
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.