I am using Springboot , I need to change the value of a variable when it is sent by JSON.
The problem is that in the database it only accepts 0 or 1 and the client expects true or false.
SpringBoot->
@JsonProperty("required")
@JsonFormat(shape = JsonFormat.Shape.BOOLEAN)
private int typerequired;
public int getTyperequired() {
return typerequired;
}
public void setTyperequired(int typerequired) {
this.typerequired = typerequired;
}
Angular2->
console.log("LOS DATOS " , data);
console.log(typeof(data[0].type));
I get 1 of type Number.
What I can see in your code:
typerequired
.required
.type
.Therefore the error should be resolved by changing
data[n].type
todata[n].required
I finally found the solution, to change the values in Java and to be able to send a JSON changing the values.