Created
May 31, 2022 12:31
-
-
Save arafathusayn/13009d5bfc054cb1e257eeb298b6bb29 to your computer and use it in GitHub Desktop.
Revisions
-
arafathusayn created this gist
May 31, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ function rawFormDataToJSON(formDataStr) { return JSON.stringify(formDataStr .trim() .split('\n') .filter(l => !l.startsWith('//')) .map(l => l.split(':')) .reduce((a, c) => ({ ...a, [c[0]]: c[1] }), {})) } // USAGE: rawFormDataToJSON(` year:2022 user_name:Customer 03 //id:1 `)