java - How to create a Json Object with empty strings and send it as a Web Service Response -


I was receiving data from the database using the spring jdbctemplate rowmapper and was getting the data. Once I get the data, I was mapping it to a Java object and converting it into a Jason object.

My JSON object contains an object with 2 field code status

When I received data from the database I had to pass successful data for fields above 200 and above 2 And Jason was passing the object as a web service response

My real question even if I did not find any data, then I am in the form of a JSN object web service response but " 404 "ADD Message Fee In the form of no data as "no data" and other fields are empty string (""), similarly if there is no exception, the json object needs to be sent with empty string, but with this 503 code < / P>

How can I do this?

My code code snippet:

  userdtls = userDaoimpl.getUserdetails (userId); If (userdtls == faucet) {Response builder builder = Response. (Converttoosson (UserDTL), MediaType.APILICANGSAN). Stats (status .NOT_FOUND) .ITI ("no such user" + UserDTL +); Throw New WebApplicationException (Builder .build ());   Status.setCode ("200"); Status.setMessage ("success"); Userdtls.setStatus (status); PersonalData Personal = New PersonalData (); Personal.setdob ("june11"); Personal.setage ("28"); Userdtls.setPersonal (personal); Gsan gsn = new gsnbilder () Serialization (). Create (); Return gson.toJson (userdtls)); Thanks  


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -