2016-03-30 5 views
0

Nun, ich versuche, eine verschachtelte JSON in Feder Controller abrufen und bekommen "Die Anfrage vom Client gesendet wurde syntaktisch falsch."Post verschachtelte Json zu Federregler mit Jackson Datenbindung

Mein Code funktioniert und bekomme die richtige Datenbindung, wenn ich kein verschachteltes JSON-Format mache, also kann ich daraus schließen, dass vielleicht etwas in meinem DTO nicht stimmt.

ROTATION Befehl:

CURL -i -H "Content-Type: application/json" -X POST http://localhost:8080/insertMapping -d '{"mapping": {"adobe_segment_id": "125", "dp_key_id": "1"}, "type": "adobe"}' 

JSON:

{"mapping": {"adobe_segment_id": "125", "dp_key_id": "1"}, "type": "adobe"} 

Controller:

@RequestMapping(value = "/insertMapping", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) 
public ResponseEntity<String> createUser(@RequestBody RequestBodyDTO mapping) { 
    LOG.info("/insertMapping" + " ,type:" + mapping.getType().getType()); 
    return null; 
} 

RequestBodyDTO:

public class RequestBodyDTO { 
private MappingDTO mapping; 
private TypeDTO type; 

public TypeDTO getType() { 
    return type; 
} 

public void setType(TypeDTO type) { 
    this.type = type; 
} 

public MappingDTO getMapping() { 
    return mapping; 
} 

public void setMapping(MappingDTO mapping) { 
    this.mapping = mapping; 
} 
} 

MappingDTO:

public class MappingDTO { 
// adobe 
private Integer adobe_segment_id; 
private Integer dp_key_id; 


public Integer getAdobe_segment_id() { 
    return adobe_segment_id; 
} 

public void setAdobe_segment_id(Integer adobe_segment_id) { 
    this.adobe_segment_id = adobe_segment_id; 
} 

public Integer getDp_key_id() { 
    return dp_key_id; 
} 

public void setDp_key_id(Integer dp_key_id) { 
    this.dp_key_id = dp_key_id; 
} 

} 

TypeDTO:

public class TypeDTO { 
private String type; 

public String getType() { 
    return type; 
} 

public void setType(String type) { 
    this.type = type; 
} 

}

Antwort

0

Problem gelöst, nachdem ich "privaten TypeDTO Typ" auf "privaten String-Typ" geändert.

Verwandte Themen