How do you trim white spaces in both the keys and values in a JavaScript Object recursively?
I came across one issue in which I was trying to \"clean\" a user suppli
I tried the solution JSON.stringify solution above, but it will not work with a string like '"this is \'my\' test"'. You can get around it using stringify's replacer function and just trim the values going in.
JSON.parse(JSON.stringify(obj, (key, value) => (typeof value === 'string' ? value.trim() : value)))