title: Json values are null while some not with GSON parsing
body: <blockquote>
  <p><em>This was my first question here :) Edited after feedback.</em></p>
  </blockquote>
  <p><strong>Objective:</strong> extract the temperature from the weather API</p>
  <p><strong>Problem:</strong>  Temperatures and other properties are returning null when parsing with GSON even when others do not.</p>
  <p>I generated the POJO classes using <a href="https://www.jsonschema2pojo.org/" rel="nofollow noreferrer">jsonschema2pojo</a> and the weird thing is that I can get some values out of it with GSON, but not others.</p>
  <p>This is the json response:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;location&quot;: {
      &quot;name&quot;: &quot;Ommoord&quot;,
      &quot;region&quot;: &quot;South Holland&quot;,
      &quot;country&quot;: &quot;Netherlands&quot;,
      &quot;lat&quot;: XXX ,
      &quot;lon&quot;: XXX ,
      &quot;tz_id&quot;: &quot;Europe/Amsterdam&quot;,
      &quot;localtime_epoch&quot;: 1647173864,
      &quot;localtime&quot;: &quot;2022-03-13 13:17&quot;
    },
    &quot;current&quot;: {
      &quot;temp_c&quot;: 14.0,
      &quot;temp_f&quot;: 57.2,
      &quot;condition&quot;: {
        &quot;text&quot;: &quot;Sunny&quot;
      },
      &quot;feelslike_c&quot;: 12.3,
      &quot;feelslike_f&quot;: 54.1,
      &quot;uv&quot;: 4.0
    }
  }
  </code></pre>
  <p>And the class for the Current object:</p>
  <pre class="lang-java prettyprint-override"><code>@JsonInclude(JsonInclude.Include.NON_NULL)
  @JsonPropertyOrder({
          &quot;temp_c&quot;,
          &quot;temp_f&quot;,
          &quot;condition&quot;,
          &quot;feelslike_c&quot;,
          &quot;feelslike_f&quot;,
          &quot;uv&quot;
  })
  @Generated(&quot;jsonschema2pojo&quot;)
  public class Current {
  
      @JsonProperty(&quot;temp_c&quot;)
      @Getter
      @Setter
      @Expose
      private Double tempC;
      @JsonProperty(&quot;temp_f&quot;)
      @Getter
      @Setter
      @Expose
      private Double tempF;
      @JsonProperty(&quot;condition&quot;)
      @Getter
      @Setter
      @Expose
      private Condition condition;
      @JsonProperty(&quot;feelslike_c&quot;)
      @Getter
      @Setter
      @Expose
      private Double feelslikeC;
      @JsonProperty(&quot;feelslike_f&quot;)
      @Setter
      @Getter
      @Expose
      private Double feelslikeF;
      @JsonProperty(&quot;uv&quot;)
      @Getter
      @Setter
      @Expose
      private Double uv;
  
  
      @Override
      public String toString() {
          StringBuilder sb = new StringBuilder();
          sb.append(Current.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('[');
          sb.append(&quot;tempC&quot;);
          sb.append('=');
          sb.append(((this.tempC == null)?&quot;&lt;null&gt;&quot;:this.tempC));
          sb.append(',');
          sb.append(&quot;tempF&quot;);
          sb.append('=');
          sb.append(((this.tempF == null)?&quot;&lt;null&gt;&quot;:this.tempF));
          sb.append(',');
          sb.append(&quot;condition&quot;);
          sb.append('=');
          sb.append(((this.condition == null)?&quot;&lt;null&gt;&quot;:this.condition));
          sb.append(',');
          sb.append(&quot;feelslikeC&quot;);
          sb.append('=');
          sb.append(((this.feelslikeC == null)?&quot;&lt;null&gt;&quot;:this.feelslikeC));
          sb.append(',');
          sb.append(&quot;feelslikeF&quot;);
          sb.append('=');
          sb.append(((this.feelslikeF == null)?&quot;&lt;null&gt;&quot;:this.feelslikeF));
          sb.append(',');
          sb.append(&quot;uv&quot;);
          sb.append('=');
          sb.append(((this.uv == null)?&quot;&lt;null&gt;&quot;:this.uv));
          sb.append(',');
          if (sb.charAt((sb.length()- 1)) == ',') {
              sb.setCharAt((sb.length()- 1), ']');
          } else {
              sb.append(']');
          }
          return sb.toString();
      }
  
  }
  
  </code></pre>
  <p>When I call them via GSON, I can get almost everything, except temperatures and localtimeEpoch. Even <strong>uv</strong> is reachable. But for some reason not the temperatures. I tried them as Double, Float and String, none work.</p>
  <pre><code>[
  location=mypackage.utils.weather.Location@7d8995e
  [
  name=Ommoord,
  region=South Holland,
  country=Netherlands,
  lat=xx.xx,lon=xx.xx,
  tzId=&lt;null&gt;,
  localtimeEpoch=&lt;null&gt;,
  localtime=2022-03-13 13:17,
  additionalProperties={}]
  ,current=mypackage.utils.weather.Current@130d63be
  [
  tempC=&lt;null&gt;,
  tempF=&lt;null&gt;,
  condition=mypackage.utils.weather.Condition@42a48628
  [
  text=Sunny,
  additionalProperties={}
  ],
  feelslikeC=&lt;null&gt;,
  feelslikeF=&lt;null&gt;,
  uv=4.0
  ]
  ,additionalProperties={}
  ]
  </code></pre>
  <p>Java code:</p>
  <pre class="lang-java prettyprint-override"><code>Gson gson= new Gson();
  Weather weatherService = gson.fromJson(json, Weather.class);
  System.out.println(weatherService.getCurrent().getTempC());
  System.out.println(weatherService.getCurrent().getCondition().getText());
  System.out.println(weatherService.getLocation().getCountry());
  </code></pre>
  <p>Note: The json string is generated via the API.</p>
  <p>Output is:</p>
  <pre><code>null
  Sunny
  Netherlands
  
  </code></pre>