Skip to content
Sharp

Networking · interview question

Why does using @JsonProperty on a field in a Java class change runtime behavior?

Multiple choiceMediumchapter-11-curatedpremiumnetworkingjackson-objectmapper
java
public class Product {
  @JsonProperty("product_id")
  private String id;
}
Choose one answer
Answer and explanation

Correct answer

D. It specifies a custom name for the field in JSON.

Why

@JsonProperty allows you to specify a custom name for a field when it is serialized to or deserialized from JSON. This can be useful when the JSON attribute does not match the Java field name.

Test yourself on Networking

A free test with instant, explained results. No account needed.

Start free test
All Networking questions →