lib/helper/sjson.js
function sanitizeKey(obj) {
  if (typeof obj !== 'object') return obj;
  if (Array.isArray(obj)) return obj;
  if (obj === null) return null;
  if (obj instanceof Boolean) return obj;
  if (obj instanceof Number) return obj;
  if (obj instanceof Buffer) return obj.toString();
  for (const k in obj) {
    const escapedK = sjs(k);
    if (escapedK !== k) {
      obj[escapedK] = sanitizeKey(obj[k]);
      obj[k] = undefined;
    } else {
      obj[k] = sanitizeKey(obj[k]);
    }
  }
  return obj;
}
function sanitizeKey(obj) {
  if (typeof obj !== 'object') return obj;
  if (Array.isArray(obj)) return obj;
  if (obj === null) return null;
  if (obj instanceof Boolean) return obj;
  if (obj instanceof Number) return obj;
  if (obj instanceof Buffer) return obj.toString();
  for (const k in obj) {
    const escapedK = sjs(k);
    if (escapedK !== k) {
      obj[escapedK] = sanitizeKey(obj[k]);
      obj[k] = undefined;
    } else {
      obj[k] = sanitizeKey(obj[k]);
    }
  }
  return obj;
}
function sanitizeKey ( obj ) { if ( typeof obj !== 'object' ) return obj ; if ( Array . isArray ( obj ) ) return obj ; if ( obj === null ) return null ; if ( obj instanceof Boolean ) return obj ; if ( obj instanceof Number ) return obj ; if ( obj instanceof Buffer ) return obj . toString ( ) ; for ( const k in obj ) { const escapedK = sjs ( k ) ; if ( escapedK !== k ) { obj [ escapedK ] = sanitizeKey ( obj [ k ] ) ; obj [ k ] = undefined ; } else { obj [ k ] = sanitizeKey ( obj [ k ] ) ; } } return obj ; }
escape json
for output json in script
escape json for output json in script