Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

formData to Json

`const formDataObject = (formData) => {

for (const key in formData) {
    if (formData[key].startsWith('{') || formData[key].startsWith('[')) {
        try {
            formData[key] = JSON.parse(formData[key]);
            console.log("key is :", key, "form data is :", formData[key]);

        } catch (error) {
            console.log("error :", key);
        }
    }
}

console.log("object", formData)
}`
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #formData #Json
ADD COMMENT
Topic
Name
7+7 =