My code is now:
import java.net.URL;
import java.util.HashMap;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.annotation.*;
public class WeatherClient {
public static void main (String[] args) {
try { final JsonNode node = new ObjectMapper().readTree(new URL("http://api.wunderground.com/api/5bef7a0ecc7f2933/" +
"conditions/q/CA/San_Francisco.json"));
}
catch (Exception exception) {
exception.printStackTrace();
}
}
}
and I get:
Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.createParser(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser; at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:1792) at WeatherClient.main(WeatherClient.java:10) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Is there any way to solve this?
Map
? Why not as aJsonNode
? – fgeJsonNode
is much more suited for JSON navigation than aMap
. – fge