JsonMappingException: Kann nicht instanziiert Wert vom Typ keinen einzigen-langen-arg-Konstruktor/factory-Methode

hi bin erste Fehler beim Versuch zu Parsen einer json-Antwort in java auf zk framework

hier ist der jason-Antwort

{"currentTime":1355390722038,"text":"OK","data":{"limitExceeded":false,"references":{"stops":[],"situations":[],"trips":[],"routes":[],"agencies":[{"id":"AG1","privateService":false,"phone":"","timezone":"Asia/Kuala_Lumpur","disclaimer":"","name":"Panorama","lang":"en","url":"http://www.allcompanyonline.com/company/33/8/26/62438/PM-Cultural--Tourism-Sdn-Bhd.html"}]},"list":[{"lonSpan":0.1766824722290039,"lon":102.2011971473685,"agencyId":"AG1","lat":2.2659808772471948,"latSpan":0.15555363245723042}]},"code":200,"version":2}

ich bekomme immer diese Fehler

com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [simple type, class com.panorama.tripplan.pojo.Agency_coverage] from Long integral number; no single-long-arg constructor/factory method

hier ist die pojo-für den root-Variablen

@JsonRootName(value = "currentTime")
public class Agency_coverage{
private Number code;
private Number currentTime;
private Data data;
private String text;
private Number version;

public Agency_coverage(){}

public Number getCode(){
    return this.code;
}
public void setCode(Number code){
    this.code = code;
}
public Number getCurrentTime(){
    return this.currentTime;
}
public void setCurrentTime(Number currentTime){
    this.currentTime = currentTime;
}
public Data getData(){
    return this.data;
}
public void setData(Data data){
    this.data = data;
}
public String getText(){
    return this.text;
}
public void setText(String text){
    this.text = text;
}
public Number getVersion(){
    return this.version;
}
public void setVersion(Number version){
    this.version = version;
}

hier ist der code, wo ich versuche zu rufen, die api und analysieren Sie die Reaktion

java.net.URLConnection connection = new URL(url + "?" + query+ "&" + queryLat+ "&" + queryLon).openConnection();
       connection.setRequestProperty("Accept-Charset", charset);
       if ( connection instanceof HttpURLConnection)
       {
         //Jackson 2.X configuration settings
            mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);

            mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
            mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
            mapper.configure(DeserializationFeature.USE_JAVA_ARRAY_FOR_JSON_ARRAY, true);
            mapper.configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true);
            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

            //Tell Jackson to expect the JSON in PascalCase, instead of camelCase
            mapper.setPropertyNamingStrategy(new PropertyNamingStrategy.PascalCaseStrategy());

          HttpURLConnection httpConnection =(HttpURLConnection) connection;  
        //Make the HTTP request, and deserialize the JSON response into the object

          Agency_coverage agencyData= new Agency_coverage();
          agencyData = mapper.readValue(agenturl, Agency_coverage.class);


          //System.out.println(agencyData.getData().getList().get(0).);
          System.out.println(agencyData.getCurrentTime());
          System.out.println(httpConnection.getResponseCode());

       }

bitte helfen Sie, wenn Sie dieses problem verstehen, ich bin ein bisschen neu für java-Entwicklung und gebe ihm meine alle

Versuchen Sie, entfernen Sie diese Anmerkung: @JsonRootName(value = "currentTime")
Hallo, wenn ich entfernen, ich bekomme diese Fehlermeldung JsonMappingException: Root name 'currentTime' does not match expected ('Agency_coverage') for type [simple type, class com.panorama.tripplan.pojo.Agency_coverage] at [Source: http://localhost:8080/api/where/agencies-with-coverage.json; line: 1, column: 2]

InformationsquelleAutor Hani | 2012-12-14

Schreibe einen Kommentar