Raja has Published 359 Articles

How to get the JsonFactory settings using Jackson in Java?

raja

raja

Updated on 07-Jul-2020 12:12:33

1K+ Views

The JsonFactory class is a thread-safe and responsible for creating instances of writer and reader. The list of settings that can be turned on/off is present in an enumeration JsonFactory.Feature, it contains static method values() that return the enum constant of this type with the specified name.Syntaxpublic static enum JsonFactory.Feature extends EnumExampleimport com.fasterxml.jackson.core.JsonFactory; ... Read More

FieldNamingPolicy enum using Gson in Java?

raja

raja

Updated on 07-Jul-2020 12:04:50

1K+ Views

Gson library provides the naming conventions as part of enum FieldNamingPolicy. We can set the field naming policy using the setFieldNamingPolicy() method of the GsonBuilder class.FieldNamingPolicy enum ConstantsIDENTITY − Using this naming policy, the field name is unchanged.LOWER_CASE_WITH_DASHES − Using this naming policy, modify the Java Field name from its camel-cased ... Read More

How to get the values of a key using the JsonPointer interface in Java?

raja

raja

Updated on 07-Jul-2020 11:58:26

857 Views

The JSONPointer is a standard that defines a string syntax that can be used to access a particular key value in the JSON document. An instance of JSONPointer can be created by calling the static factory method createPointer() on the Json class. In the JSONPointer,  every string syntax is prefixed with “/”. We can ... Read More

Importance of the JsonPatch interface in Java?

raja

raja

Updated on 07-Jul-2020 11:55:50

668 Views

The JsonPatch interface is a format for storing a sequence of operations that can be applied to the target JSON structure. There are few operations like add, remove, replace, copy, move and test can be stored in JsonPath and operated on JSON structure. The JsonPatchBuilder interface can be used for constructing a JSON patch ... Read More

How to create a JSON using JsonObjectBuilder and JsonArrayBuilder in Java?

raja

raja

Updated on 07-Jul-2020 11:43:40

10K+ Views

The JsonObjectBuilder can be used for creating JsonObject models whereas the JsonArrayBuilder can be used for creating JsonArray models. The JsonObjectBuilder can be created using the Json class, it contains methods to create the builder object and build an empty JsonObject instance using the Json.createObjectBuilder().build(). The JsonArrayBuilder can be created using the Json class, it contains methods to ... Read More

How to parse a JSON string using Streaming API in Java?

raja

raja

Updated on 07-Jul-2020 07:40:21

3K+ Views

The Streaming API consists of an important interface JsonParser and this interface contains methods to parse JSON in a streaming way and provides forward, read-only access to JSON data. The Json class contains the methods to create parsers from input sources. We can parse a JSON using the static method createParser() of Json class.Syntaxpublic static JsonParser ... Read More

How to create a JSON Object using Object Model in Java?

raja

raja

Updated on 07-Jul-2020 07:25:17

3K+ Views

The javax.json.JsonObject interface can represent an immutable JSON object value and provides an unmodifiable map view to the JSON object name/value mappings. A JsonObject instance can be created from an input source using the static method readObject() of javax.json.JsonReader class and also can be created using the static method createObjectBuilder() of javax.json.Json class.Syntaxpublic static JsonObjectBuilder createObjectBuilder()Exampleimport java.io.*; import ... Read More

How to convert a JSON object to an enum using Jackson in Java?

raja

raja

Updated on 07-Jul-2020 05:29:47

5K+ Views

A JSONObject can parse the text from String to produce a Map kind of an object. An Enum can be used to define a collection of constants, when we need a predefined list of values which do not represent some kind of numeric or textual data then we can use an enum. We ... Read More

What is the use of @JacksonInject annotation using Jackson in Java?

raja

raja

Updated on 06-Jul-2020 13:35:24

683 Views

The Jackson @JacksonInject annotation can be used to inject the values into parsed objects instead of reading those values from the JSON. In order to inject values into a field, we can use the InjectableValues class and need to configure the ObjectMapper class to read both the injected values from the InjectableValues class ... Read More

How to add a JSON string to an existing JSON file in Java?

raja

raja

Updated on 06-Jul-2020 13:21:04

7K+ Views

A Gson is a json library for Java and it can be used to generate a JSON. In the initial step, we can read a JSON file and parsing to a Java object then need to typecast the Java object to a JSonObject and parsing to a JsonArray. Then iterating this JSON array ... Read More

Advertisements