1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-07 04:20:05 +00:00
Files
adapter/src/utils/serialize.ts
2020-09-01 14:28:15 +03:00

16 lines
440 B
TypeScript

export const serialize = (obj: any) => {
const str: any[] = []
for (const p in obj) {
if (obj.hasOwnProperty(p)) {
if (obj[p] instanceof Array) {
for (let i = 0, n = obj[p].length; i < n; i++) {
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p][i]))
}
} else {
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]))
}
}
}
return str.join('&')
}