Importieren json-URL für java und analysieren es mit jackson-Bibliothek

Ich versuche zu Lesen ein json-link in java und analysiert, so kann ich es verwenden, für andere Angelegenheiten, aber das problem ist, dass ich Fehler, die ich weiß wirklich nicht, was zu tun ist.
Hier ist der code:

package weather.data;

import weather.data;

import com.fasterxml.jackson.core.JsonParseException;
//import com.fasterxml.jackson.annotation.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.JsonMappingException;

import java.io.File;
import java.net.URI;
import java.io.IOException;

public class usertest {

    public static void main() throws JsonParseException, JsonMappingException, IOException 
    {

        URI jsonUrl = new URI("https://gist.githubusercontent.com/anonymous/4b32c7ef1ceb5dd48bf5/raw/ef1987551faa3fb61473bb0e7aad70a228dc36d6/gistfile1.txt");

        ObjectMapper mapper = new ObjectMapper();

        City = mapper.readValue(jsonUrl, data.class);
    }

}

Hier sind die Fehler:
über import-Wetter.Daten:Mehrere Marker in dieser Zeile
- Nur eine Art importiert werden können. Wetter.Daten, die aufgelöst wird
Paket
- Die import-Wetter.die Daten werden nie verwendet

in der Stadt = mapper.readValue(jsonUrl, data.class):Mehrere Marker in dieser Zeile
- Daten können nicht aufgelöst werden, zu einer Art
- Stadt nicht gelöst werden können, um eine variable
- Die Methode readValue(JsonParser, Klasse) in der Art ObjectMapper ist nicht anwendbar für die
Argumente (URI, Klasse)
- Die Methode readValue(JsonParser, Klasse) in der Art ObjectMapper ist nicht anwendbar für die
Argumente (URI, Klasse)
- Stadt nicht gelöst werden können, um eine variable
- Daten können nicht aufgelöst werden, zu einer Art

Irgendwelche Ideen? Auch ich verstehe wirklich nicht, das Konzept der mit-mapper.readValue. würde mir einer helfen bitte?

Hinweis: ich verwendete json-gen zu erzeugen, die Daten von Objekten innerhalb des link-und jetzt habe ich-Objekt-Daten java-Dateien: Stadt, Coord, List1, Temp und Wetter mit dem folgenden Inhalt.

Für City.java als Beispiel:

package weather.data;

import java.util.List;

public class City{
    private Coord coord;
    private String country;
    private Number id;
    private String name;
    private Number population;

    public Coord getCoord(){
        return this.coord;
    }
    public void setCoord(Coord coord){
        this.coord = coord;
    }
    public String getCountry(){
        return this.country;
    }
    public void setCountry(String country){
        this.country = country;
    }
    public Number getId(){
        return this.id;
    }
    public void setId(Number id){
        this.id = id;
    }
    public String getName(){
        return this.name;
    }
    public void setName(String name){
        this.name = name;
    }
    public Number getPopulation(){
        return this.population;
    }
    public void setPopulation(Number population){
        this.population = population;
    }
}

Vielen Dank im Voraus

InformationsquelleAutor zahra | 2014-05-05

Schreibe einen Kommentar