Reputation: 327
I have a script that I'm working on, this script reads a zip file and extracts the contents of the files inside the zip. What I'm trying to do is send a request to my server in the following format:
file0name,contentfile0;file1name,contentfile1;file2name,contentfile2
Can someone tell me what type of data structure I should use? Is it a list or a JSON object?
https://jsfiddle.net/ker1w6pb/6/
Upvotes: 0
Views: 63
Reputation: 7379
Assuming you convert your content into a string (which sounds odd to me), you can just POST a JSON data object containing your string:
var postData = [{
filename: 'file0',
content: 'content0'
}, {
filename: 'file1',
content: 'content1'
}, {
filename: 'file2',
content: 'content2'
}];
var postString = postData.reduce(function(previous, current) {
return previous + current.filename + ',' + current.content + ';';
}, '');
//post(uri, {data: postString});
document.write(postString);
Upvotes: 2