function convertBlankStringsToNull(obj) {
const newObj = { ...obj };
for (const key in newObj) {
if (typeof newObj[key] === 'string' && newObj[key].trim() === '') {
newObj[key] = null;
}
}
return newObj;
}
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme