Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //create myData object as shown in question
- myData = {};
- myData[1] = 'hello';
- myData[2] = 'goodbye';
- myData[3] = {};
- myData[3][1] = 'sub1';
- myData[3][2] = 'sub2';
- myData[3][3] = 'sub3';
- //create config object for use with source code
- config = {};
- config.data = myData;
- //execute source code snippet
- var pairs = [];
- for (var key in config.data) {
- if (config.data.hasOwnProperty(key)) {
- pairs.push(encodeURIComponent(key) + "=" + encodeURIComponent(config.data[key]));
- }
- }
- var data = pairs.join("&");
- //
- console.log(data);
- //result
- 1=hello&2=goodbye&3=%5Bobject%20Object%5D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement