title: Leaving out undef'ed keys from Perl-JSON-module-encoded output
body: <p>I am using the <a href="http://search.cpan.org/~makamaka/JSON-2.53/lib/JSON.pm" rel="nofollow">Perl JSON</a> module to encode some nested Perl object and array references (obtained from decoding JSON input) into pretty-printed JSON output. </p>
  
  <p>So far, so good. However, I have a key that I'd like to remove from my reference input:</p>
  
  <pre><code>if (defined $originalJSON-&gt;{'myObsoleteKey'}) {
      undef $originalJSON-&gt;{'myObsoleteKey'};
  }
  </code></pre>
  
  <p>It looks like this gets rendered into a <code>null</code> JSON element in my output:</p>
  
  <pre><code>{
      ...
      "myObsoleteKey" : null, 
      ...
  }
  </code></pre>
  
  <p>I'd prefer to filter this out entirely. I guess I could write an <code>awk</code> script or something similar to do this manually, but I'm hoping there's a cleaner way to do this within the Perl JSON module. Is this doable?</p>