Bird
0
0

Which annotation in Spring Boot helps automatically convert Java objects to JSON in REST responses?

easy📝 Conceptual Q2 of 15
Spring Boot - Messaging
Which annotation in Spring Boot helps automatically convert Java objects to JSON in REST responses?
A@ResponseBody
B@JsonSerialize
C@Entity
D@Autowired
Step-by-Step Solution
Solution:
  1. Step 1: Identify annotation for REST response serialization

    @ResponseBody tells Spring Boot to convert the returned object into JSON automatically.
  2. Step 2: Differentiate from other annotations

    @JsonSerialize is for custom serialization, @Entity is for database mapping, @Autowired is for dependency injection.
  3. Final Answer:

    @ResponseBody -> Option A
  4. Quick Check:

    Automatic JSON conversion = @ResponseBody [OK]
Quick Trick: Use @ResponseBody to send JSON from controller methods [OK]
Common Mistakes:
  • Confusing @JsonSerialize with automatic JSON conversion
  • Using @Entity for serialization
  • Mixing dependency injection with serialization

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes