showing results for - "json to formdata"
Gerald
20 Jan 2019
1var object = {};
2formData.forEach(function(value, key){
3    object[key] = value;
4});
5var json = JSON.stringify(object);
6
7// Or ES6 arrow function
8var object = {};
9formData.forEach((value, key) => object[key] = value);
10var json = JSON.stringify(object);
11
Carolina
24 Mar 2016
1function buildFormData(formData, data, parentKey) {
2  if (data && typeof data === 'object' && !(data instanceof Date) && !(data instanceof File)) {
3    Object.keys(data).forEach(key => {
4      buildFormData(formData, data[key], parentKey ? `${parentKey}[${key}]` : key);
5    });
6  } else {
7    const value = data == null ? '' : data;
8
9    formData.append(parentKey, value);
10  }
11}
12
13function jsonToFormData(data) {
14  const formData = new FormData();
15  
16  buildFormData(formData, data);
17  
18  return formData;
19}
20
21const my_data = {
22  num: 1,
23  falseBool: false,
24  trueBool: true,
25  empty: '',
26  und: undefined,
27  nullable: null,
28  date: new Date(),
29  name: 'str',
30  another_object: {
31    name: 'my_name',
32    value: 'whatever'
33  },
34  array: [
35    {
36      key1: {
37        name: 'key1'
38      }
39    }
40  ]
41};
42
43jsonToFormData(my_data)
44
Dylan
07 Apr 2016
1var object = {};
2formData.forEach(function(value, key){
3    object[key] = value;
4});
5var json = JSON.stringify(object);
6
Erika
11 Sep 2020
1`const formDataObject = (formData) => {
2
3for (const key in formData) {
4    if (formData[key].startsWith('{') || formData[key].startsWith('[')) {
5        try {
6            formData[key] = JSON.parse(formData[key]);
7            console.log("key is :", key, "form data is :", formData[key]);
8
9        } catch (error) {
10            console.log("error :", key);
11        }
12    }
13}
14
15console.log("object", formData)
16}`
17
queries leading to this page
convert json data to form dataformdata to json conveterjavascript turn json to formdatahow to pass json object in formdataformdata to json jqueryformdata to json onlinecreate object and parse to json in formjson data to create the formconvert formdata to json using javascriptmake json from form datajson convert form datahow to submit data from html form into a json fieldsend json formdataconvert form to json objectcan i use formdata and json body togetherjson raw to formdata converterjavascript json formdatahow to send json and formdatasubmit json data in formform to json datafrom serlize to jsonhow to convert json to form datasend form data to jsonformdata json valueformdata to json jsjson format instead of a formdatahow to make data from form to json formatraw json converter formdataform data as jsonhtml form data send jsoncreate form data object from jsonformdata javascript jsonjson for form dataformdata type jsonjson or formdataconvert formdata from jsonconvert formdat 5bobject object 5d to a jsoncreate form from json datanew formdata jsonjson to formdata onlineformdata and json in one requestnew formdata 28 29 return object or json 3fform data in jsonsend json object in formdataform data convert into json datapass formdata in a jsonjson to form data formatformdata json valuesend a json object in formdataform data jsonhow to convert json request to form dataconvert formdata to json onlinesend form data as jsonjavascript json to formdataformdata or jsonconvert json to formdataformdata to json javascriptjson as form datadata form to jsonjson to formdata jsjavascript formdata to jsonconvert json to formdata angular 7post form data as jsonsend form data in json formatsimple form to json dataform data json objecthow to set formdata value into jsonsend json to formdatahow to get form data as jsonjson in formdata jsformdata string to jsonform data object to jsonformdata jsoncreate form data from jsonformdata 28 29 json getjson in formdatajs convert form data to jsoncreate formdata from jsonconvert json to form datacollect formdata in jsoncan you pass formdata in jsonconvert json into form dataformdata object from jsonturn formdata to jsonconvert form to jsonformdata js to jsonconvert form data into jsonsend formdata as jsonform json datahow to convert form data to jsonconvert formdata to jsonfrom json to form datapass json in formdataform to jsonjson to formdataconvert form data to jsonform data to jsonadd formdata to jsonjson formdatajson to formdata key valuesformdata send jsonjson to form dataformdata add jsonformdata to jsonconvert html form data to jsonjs convert formdata to jsonformdata with jsonjson to formdata javascripthow to parse formdata to jsonformdata entries to jsonpass json to formdataget form data as jsonhow to put formdata in a json bodysending json or formdataformdata into json objecthow to attach json to formdatajson to form data getformdata javascript to jsonpass json data in formdataform data into jsonhow to send json with formdataform data from jsonjavascript formdata jsonsending formdata as jsonchange a json object to formdataconvert formdata object to jsonadd json to formdataform data inside jsonhtml form to jsonhow to convert form data in jsonsend formdata within a body jsonget json from formdataformdata object to jsonjson form datajs formdata to jsonjs formdata add jsonjavascript formdata jsonjson to form dataform data as json objectformdata entries to jsoncan i send a json object with formdata in itpython convert json to formdataangular formdata to jsonformdata json structureconvert json to formdata javascriptjs json to formdataformdata value jsonformdata from jsonjson with formdataformdata as jsonconvert formdata to json javascripthow to convert formdata 28html5 object 29 to jsonsend json data in formdata javamake formdata to jsonjson convert to formdataformdata and json togetherchanging json into form dataconvert forma data to jsonconvert formdata field to jsonhow to submit data from form into a json fieldhow to make form data into jsonform data to jsonconvert form json into formdatasend json data in formdatahow to convert formdata to jsonhow to convert json data to formdataform data and jsonformdata en formato jsonform data convert to jsonhow to convert form data into jsoncreating a json from formdata in javascriptvanilla js function to get data out of form as jsonform data json objectturn json into formdatanew formdata 28 29 return object or jsonparse formdata to jsonconverting form data to jsonhow to sen formdata and json seperatehow to send json object in formdatasend json from formdatajavascript formdata object to jsonform data string to jsonsend json inside formdatagenerate formdata from a json objectjson to formdata