One of my JSON content has number for entityTypeId, how to change this to a String ?
eg change 1 to "1".
JSON
[
{
entityTypeId: 3,
entityTypeName: "Branch of Legal Entity"
},
{
entityTypeId: 1,
entityTypeName: "Legal Entity"
},
{
entityTypeId: 2,
entityTypeName: "Notional Entity"
}
]
REST API
@GET
@Path(value = "/entityTypes")
@Produces(MediaType.APPLICATION_JSON)
@Override
public List<EntityType> getEntityTypes() {
return commonBusiness.getEntityTypes();
}
JPA Entity
public class EntityType implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="ENTITY_TYPE_ID")
private long entityTypeId;
@Column(name="ENTITY_TYPE_NAME")
private String entityTypeName;
Update:
Many of you asked why I need to change to a String. I use this JSON data to render a drop-down. This drop down value (entityTypeId) saves in the DB in a number column successfully. But when I load the view page the drop-down is not loaded with that value. Other drop downs work which has both those values as String.
Earlier I raised a separated issue Angularjs - dropdown - Should the key/value pair always be a string data type