@ajoelp/json-to-formdata
Version:
Convert json data to a FormData object
62 lines (60 loc) • 1.09 kB
text/typescript
export const payload = {
a: true,
b: false,
c: 'string',
d: 2,
e: new File([], ''),
f: new Blob(),
g: {
a: true,
b: false,
c: 'string',
d: 2,
e: new File([], ''),
f: new Blob(),
},
h: [
{
a: true,
b: false,
c: 'string',
d: 2,
e: new File([], ''),
f: new Blob(),
},
{
a: true,
b: false,
c: 'string',
d: 2,
e: new File([], ''),
f: new Blob(),
},
],
};
export const result = [
['a', 'true'],
['b', 'false'],
['c', 'string'],
['d', '2'],
['e', new File([], '')],
['f', new File([], '')],
['g[a]', 'true'],
['g[b]', 'false'],
['g[c]', 'string'],
['g[d]', '2'],
['g[e]', new File([], '')],
['g[f]', new File([], '')],
['h[0][a]', 'true'],
['h[0][b]', 'false'],
['h[0][c]', 'string'],
['h[0][d]', '2'],
['h[0][e]', new File([], '')],
['h[0][f]', new File([], '')],
['h[1][a]', 'true'],
['h[1][b]', 'false'],
['h[1][c]', 'string'],
['h[1][d]', '2'],
['h[1][e]', new File([], '')],
['h[1][f]', new File([], '')],
];