Skip to content

Instantly share code, notes, and snippets.

/**
* ps_Nest Thermostat
*
* Copyright 2014 Patrick Stuart
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@ThePVD
ThePVD / postmanEmptyCellsDeleter.js
Created July 9, 2021 02:15 — forked from Mondonno/postmanEmptyCellsDeleter.js
Empty JSON cells deleter (can be used in Postman prerequests)
const deleteEmptyValues = (body) => {
let obj = {};
let keys = (bb) => (!Object.keys(bb).length && Object.keys(bb).length !== undefined)
typeof body === 'string' ? body = JSON.parse(body) : null;
for (const key in body) {
let skip = [false];
if (body.hasOwnProperty(key))
if ((body[key] !== false && !body[key]) || (body[key].length !== undefined && !body[key].length)) { skip[0] = true; }
else
if (typeof body[key] === 'object') {