title: How to handle a null value in JSON-Simple?
body: <p>I'm ingesting tweets in JSON using JSON-Simple. I split the user object off into it's own JSONObject class, in memory:</p>
  
  <pre><code>incomingUser = (JSONObject) incomingTweet.get("user");
  </code></pre>
  
  <p>Then I'm stripping off various fields from the tweet and the user objects using JSON-Simple; I was doing</p>
  
  <pre><code>strippedJSON.put("userLocation", incomingUser.get("location").toString();
  </code></pre>
  
  <p>But it turns out that occasionally a user's location is set to <code>null</code>.</p>
  
  <p>So now I'm checking to see if the field I'm stripping is null, and setting it to "":</p>
  
  <pre><code>strippedJSON.put("userLocation", (incomingUser.get("location").toString().equals(null)?
          "": incomingUser.get("location").toString());
  </code></pre>
  
  <p>But I've stepped through eclipse in debug mode and found someone who's location is set to null, and stepped over the part where I strip out the JSON object field associated with <code>"location"</code> and put it into the JSON object field <code>"user Location"</code>. And I get a NPE.</p>
  
  <p>Does my ternary statement not account for that? I'd have though it would check if it was equal to null (there only being one 'null object' it should be able to see the pointers are the same) if it is (<code>condtion?</code> is true) it should evaluate to <code>put("location","")</code> no?</p>
  
  <p>Where am I going wrong? What should I do instead to handle this null value?</p>