java - Pass point object into @RequestBody -
i'm developing rest api service using spring boot.my project has entity class named carwash fields
import com.vividsolutions.jts.geom.point; @column(columndefinition = "point", name = "lon_lat") private point lonlat; @column(name = "address") private string address; this controller method
@requestmapping(value = "owner/carwashs", method = requestmethod.post, produces = "application/json;charset=utf-8") @responsebody public responseentity<string> createcarwash(@requestparam(value = "sid", required = true, defaultvalue = "") string sid, @requestbody carwash carwash) throws timeoutexception, sockettimeoutexception, socketexception { final integer id = checksession(sid); system.out.println(carwash.getlonlat()); system.out.println(carwash.getaddress()); return responseentity.ok(createcarwashlogic(carwash)); } when call method using json {"address":"qwerty"}it's work fine. question how can add lonlat property request body in order jackson able parse point object?
suppose have
class point{ string attribute1; string attribute2; }
send carwash json
{ "address":"qwerty", "lonlat" : { "attribute1":"value", "attribute2":"value" } }
and jackson set attribute values accordingly.
Comments
Post a Comment