Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json Boolean values are not being captured in the project #2351

Closed
ved-asole opened this issue Jan 7, 2024 · 2 comments
Closed

Json Boolean values are not being captured in the project #2351

ved-asole opened this issue Jan 7, 2024 · 2 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@ved-asole
Copy link

Hi Team,

The json boolean values are not being captured from the JSON body that was sent from the POST request. Could you please look into the below issue as soon as possible?

Below are the Details :

POJO :

@AllArgsConstructor
@NoArgsConstructor
@Validated
@Entity
@Table(name = "category")
public class Category {

    @Id
    @Column(updatable = false)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "category_seq")
    @SequenceGenerator(name = "category_seq", allocationSize = 0)
    private long categoryId;

    @Column(nullable = false, length = 20)
    private String name;

    private String image;
    private String desc;

    @ManyToOne
    @JoinColumn(name = "parent_category_id")
    private Category parentCategory;

    @JsonProperty
    private boolean isActive;

    public boolean getIsActive() {
        return isActive;
    }

    public void setIsActive(boolean isActive) {
        this.isActive = isActive;
    }
    
    ........other getters and setters.......

JSON Request :

Url : http://localhost:8000/categories
Method : POST
Request Body :

{
  "categoryId": 1,
  "name": "Top Offers",
  "image": "https://rukminim1.flixcart.com/fk-p-flap/64/64/image/085406bae47866d5.png?q=100",
  "desc": "Top Offers on Mobile Phones",
  "parentCategory":{},
  "isActive":true
}

Response from API :

{
    "name": "Top Offers",
    "image": "https://rukminim1.flixcart.com/fk-p-flap/64/64/image/085406bae47866d5.png?q=100",
    "desc": "Top Offers on Mobile Phones",
    "isActive": false,
    "_links": {
        "self": {
            "href": "http://localhost:8000/categories/1"
        },
        "category": {
            "href": "http://localhost:8000/categories/1"
        },
        "parentCategory": {
            "href": "http://localhost:8000/categories/1/parentCategory"
        }
    }
}
@ved-asole
Copy link
Author

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 7, 2024
@odrotbohm
Copy link
Member

The type is not following the Java beans convention for primitive boolean. See more on this here. So generally speaking, this is a simple Jackson issue and has got nothing to do with either Boot or Spring Data REST.

@odrotbohm odrotbohm added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants