
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9150 Articles for Object Oriented Programming

1K+ Views
The @JsonIdentityInfo annotation is used when an object has a parent-child relationship in the Jackson library. The @JsonIdentityInfo annotation is used to indicate the object identity during the serialization and deserialization process. The ObjectIdGenerators.PropertyGenerator is an abstract place-holder class to denote a case where Object Identifier to use comes from a POJO property.Syntax@Target(value={ANNOTATION_TYPE, TYPE, FIELD, METHOD, PARAMETER}) @Retention(value=RUNTIME) public @interface JsonIdentityInfoExampleimport java.util.*; import java.io.*; import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.ObjectIdGenerators; import com.fasterxml.jackson.databind.ObjectMapper; public class JsonIdentityInfoTest { public static void main(String[] args) throws IOException { ObjectMapper mapper = new ObjectMapper(); User user = new User(115, "Raja", "Ramesh"); ... Read More

2K+ Views
The JSONArray is a sequence of values, the external text is a string enclosed in square brackets with commas separating the values and internal text is an object having get() and opt() methods, we need to access those values by index. The element() method for adding or replacing those values. An array is an object that stores multiple values of the same type. It can hold both primitive types and object references. We can convert a JSON array to array by using the toArray() method of JSONArray class. This method produces an Object[] with the contents of JSONArray.Syntaxpublic Object[] toArray()Exampleimport java.util.Arrays; import net.sf.json.JSONArray; public ... Read More

441 Views
The @Since annotation can use with the setVersion() method of the GsonBuilder class. This annotation can apply to a field in java class and accepts float as an argument. This argument represents the version number in which the field has serialized. The same can apply to the deserialization process.Syntax@Documented @Retention(value=RUNTIME) @Target(value={FIELD, TYPE}) public @interface SinceExampleimport com.google.gson.annotations.Since; import com.google.gson.Gson; import com.google.gson.GsonBuilder; public class GsonSinceAnnotationTest { public static void main(String[] args) { Employee emp = new Employee(); emp.setEmployeeName("Raja Ramesh"); emp.setEmployeeId(125); emp.setEmployeeTechnology("Java"); emp.setEmploeeAddress("Hyderabad"); System.out.println("Since version ... Read More

352 Views
The @Until annotation can use with the setVersion() method of the GsonBuilder class. This annotation can apply to a field in java class and accepts float as an argument. This argument represents the version number in which the field has serialized. The @Until annotation can manage the versioning of JSON classes in web-services.Syntax@Documented @Retention(value=RUNTIME) @Target(value={FIELD, TYPE}) public @interface UntilExampleimport com.google.gson.annotations.Until; import com.google.gson.Gson; import com.google.gson.GsonBuilder; public class GsonUntilAnnotationTest { public static void main(String[] args) { Employee emp = new Employee(); emp.setEmployeeName("Adithya"); emp.setEmployeeId(115); emp.setEmployeeTechnology("Python"); emp.setEmploeeAddress("Pune"); ... Read More

1K+ Views
In Java, Jackson is a library that is used to convert JSON to Java objects and vice versa. Jackson Annotations are used during serialization and deserialization. We use annotations with a particular field or method that is declared in Java. So, Annotations make the JSON output clearer as we required. In this Article, we will learn about one of its annotations @JsonRootName. @JsonRootName Annotatation The @JsonRootName annotation is a Jackson annotation that is used on a class if we want to do wrapping in our JSON attributes. It is a class-level annotation. It wraps the object to be serialized with a ... Read More

2K+ Views
In Java, Jackson is a library that is used to convert JSON to Java objects and vice versa. Jackson Annotations are used during serialization and deserialization to denote a particular field that is declared in Java as an instance variable, is a JsonProperty, and should be ignored. We can also use annotations with methods. So, basically, Annotations make JSON output clearer as we required. In this Article, we will learn about one of its annotations is @JsonRawValue Annotation. @JsonRawValue This annotation can be used for methods and fields. The @JsonRawValue annotation is used to serialize methods or fields as it ... Read More

3K+ Views
The JSONObject class is a collection of name/value pairs (unordered) where the bean is a class with setter and getter methods for its member fields. We can convert a JSON object to a bean using the toBean() method of JSONObject class.Syntaxpublic static Object toBean(JSONObject jsonObject, Class beanClass)Exampleimport net.sf.json.JSONObject; public class ConvertJSONObjToBeanTest { public static void main(String[] args) { mployee emp = new Employee("Sai", "Ram", 30, "Bangalore"); JSONObject jsonObj = JSONObject.fromObject(emp); System.out.println(jsonObj.toString(3)); // pretty print JSON emp = (Employee)JSONObject.toBean(jsonObj, Employee.class); System.out.println(emp.toString()); } // Employee class public static ... Read More

1K+ Views
The @JsonFilter annotation belongs to Jackson Annotations. Jackson Annotations are used during serialization and deserialization to denote a particular field (or method) that is declared in Java as an instance variable, is a JsonProperty, and should be ignored, or what condition should be applied to it. It is used to define a dynamic filter for serializing/deserializing Java objects. @jsonfilter annotation Let's discuss the importance of jsonfilter annotation as given below - It is used to filter which fields or properties of an object should be included ... Read More

1K+ Views
Jackson Library: The @JsonView AnnotationIn Java, Jackson is a library that is used to convert JSON to Java objects and vice versa. Jackson Annotations are used during serialization and deserialization. We use these to denote or specify annotations before a particular field or method (that is declared in Java). Using an annotation before a field, we can denote whether a variable is a JsonProperty, should be ignored, or what condition should be applied to it. The JsonView annotation is used to include/exclude ... Read More

488 Views
The JsonConfig class can be used to configure the serialization process. We can use the setJsonPropertyFilter() method of JsonConfig to set the property filter when serializing to JSON. We need to implement a custom PropertyFilter class by overriding the apply() method of the PropertyFilter interface. It returns true if the property will be filtered out or false otherwise.Syntaxpublic void setJsonPropertyFilter(PropertyFilter jsonPropertyFilter)Exampleimport net.sf.json.JSONObject; import net.sf.json.JsonConfig; import net.sf.json.util.PropertyFilter; public class ConvertBeanToJsonExcludeFilterTest { public static void main(String[] args) { Student student = new Student("Sai", "Chaitanya", 20, "Hyderabad"); JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setJsonPropertyFilter(new CustomPropertyFilter()); ... Read More