我正在尝试处理我将从 httprequest 获得的 json 到一个类中。但问题是当我尝试将数据保存到我的班级时,他会一直崩溃
Boolean hasmore = tree.get("has_more").getBooleanValue();
if (hasmore == true) {
System.out.println("Ik geraak hier");
JsonNode resourceArrayNode=tree.get("photos");
for(JsonNode jsonNode:resourceArrayNode){
int height=jsonNode.get("height").getIntValue();
result[i].setHeight(height);
//System.out.println(result[i].getHeight());
i++;
}
所以这是处理图片高度的代码。问题是,当我使用 javaexceptionpointer 将其设置为我的班级时,他会崩溃,我觉得这很奇怪,因为一切都已正确设置
Exception in thread "main" java.lang.NullPointerException
at com.hp.gisware.panoramio.PanoramioResponseDeserializer.deserialize(PanoramioResponseDeserializer.java:29)
at com.hp.gisware.panoramio.PanoramioResponseDeserializer.deserialize(PanoramioResponseDeserializer.java:15)
at org.codehaus.jackson.map.ObjectReader._bindAndClose(ObjectReader.java:768)
at org.codehaus.jackson.map.ObjectReader.readValue(ObjectReader.java:460)
at com.hp.gisware.panoramio.GenericJsonPanoramioGeocoder.transmitLocation(GenericJsonPanoramioGeocoder.java:33)
at com.hp.gisware.panoramio.PanoramioRunner.main(PanoramioRunner.java:26)
Disconnected from the target VM, address: '127.0.0.1:58050', transport: 'socket'