- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Raja has Published 760 Articles
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
raja
601 Views
The ExclusionStrategy interface can be used to exclude any field during serialization and deserialization. We can provide a custom implementation of the ExclusionStrategy interface and need to register it with GsonBuilder using the setExclusionStrategies() method. It configures Gson to apply a set of exclusion strategies during serialization and deserialization.Syntaxpublic GsonBuilder setExclusionStrategies(ExclusionStrategy... strategies)Exampleimport com.google.gson.*; import ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
raja
6K+ Views
The JsonBuilderFactory interface is a factory to create JsonObjectBuilder instance and JsonObjectBuilder is a builder for creating JsonObject models from scratch. This interface initializes an empty JSON object model and provides methods to add name/value pairs to the object model and to return the resulting object. We can create a JsonObjectBuilder instance that can be used ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
raja
4K+ Views
JSON Schema is a specification for JSON based format for defining the structure of JSON data. The JsonSchema class can provide a contract for what JSON data is required for a given application and how to interact with it. The JsonSchema can define validation, documentation, hyperlink navigation, and interaction control of JSON ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
raja
6K+ Views
The Java Arrays are objects which store multiple variables of the same type, it holds primitive types and object references and an ArrayList can represent a resizable list of objects. We can add, remove, find, sort and replace elements using the list. A JsonArray can parse text from a string to produce a ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
raja
2K+ Views
The org.json.simple library allows us to read and write JSON data in Java. In other words, we can encode and decode the JSON object. The org.json.simple package contains important classes like JSONValue, JSONObject, JSONArray, JsonString and JsonNumber. We need to install the json-simple.jar file to execute a JSON program whereas org.json library has classes to ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
raja
16K+ Views
While deserializing, a Gson can expect a JSON object but it can find a JSON array. Since it can't convert from one to the other, it can throw an error as "JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY" at the runtime.Exampleimport com.google.gson.Gson; public class GsonErrorTest { public static void ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
raja
2K+ Views
The javax.json.JsonWriter interface can write a JSON object or array structure to an output source. The class javax.json.JsonWriterFactory contains methods to create JsonWriter instances. A factory instance can be used to create multiple writer instances with the same configuration. We can create writers from output source using the static method createWriter() of javax.json.Json class.Syntaxpublic static JsonWriter createWriter(Writer ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
raja
2K+ Views
The DeserializationProblemHandler class can be registered to get called when a potentially recoverable problem is encountered during the deserialization process. We can handle the errors generated while deserializing the JSON by implementing the handleUnknownProperty() method of DeserializationProblemHandler class.Syntaxpublic boolean handleUnknownProperty(DeserializationContext ctxt, JsonParser p, JsonDeserializer deserializer, Object beanOrClass, String propertyName) throws IOExceptionExampleimport java.io.*; ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
raja
680 Views
The JsonParserSequence is a helper class that can be used to create a parser containing two sub-parsers placed in a particular sequence. We can create a sequence using the static method createFlattened() of the JsonParserSequence class.Syntaxpublic static JsonParserSequence createFlattened(JsonParser first, JsonParser second)Exampleimport java.io.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.util.*; public class JsonParserSequenceTest { public static void main(String[] ... Read More
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
raja
3K+ Views
The ObjectMapper class provides functionality for converting between Java objects and matching JSON constructs. We can achieve mapping of JSON data represented by an Object Model to a particular Java object using a tree-like data structure that reads and stores the entire JSON content in memory. In the first step, read ... Read More