@JsonUnwrapped টীকা৷ সিরিয়ালাইজেশন এবং ডিসিরিয়ালাইজেশন প্রক্রিয়া চলাকালীন মানগুলি খুলতে ব্যবহার করা যেতে পারে। এটি একটি কম্পোজড ক্লাসের মান রেন্ডার করতে সাহায্য করে যেন এটি প্যারেন্ট ক্লাসের অন্তর্গত।
সিনট্যাক্স
@Target(value={ANNOTATION_TYPE,FIELD,METHOD,PARAMETER})
@Retention(value=RUNTIME)
public @interface JsonUnwrapped উদাহরণ
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.JsonProcessingException;
public class JsonUnwrappedAnnotationTest {
public static void main(String args[]) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(new Employee());
System.out.println(jsonString);
}
}
class Employee {
public int empId = 110;
public String empName = "Raja Ramesh";
@JsonUnwrapped
public Address address = new Address();
// Address class
public static class Address {
public String doorNumber = "1118";
public String street = "madhapur";
public String pinCode = "500081";
public String city = "Hyderabad";
}
} আউটপুট
{
"empId" : 110,
"empName" : "Raja Ramesh",
"doorNumber" : "1118",
"street" : "madhapur",
"pinCode" : "500081",
"city" : "Hyderabad"
}