In this post under Jackson YAML, I will show with example how to check whether a yaml parser feature is enabled or not. In previous post under Jackson YAML, I explained the purpose of yaml parser feature “YAMLParser.Feature.PARSE_BOOLEAN_LIKE_WORDS_AS_STRINGS”. For our example I will check whether the above parser feature is enabled or not. Below is…… Continue reading Checking whether yaml parser feature is enabled or not
Tag: Streaming
Yaml parser feature PARSE_BOOLEAN_LIKE_WORDS_AS_STRINGS
In this post under Jackson Yaml, I will explain the purpose of parser feature “PARSE_BOOLEAN_LIKE_WORDS_AS_STRINGS” and how to enable or disable it. We all know that YAML parser, when parsing a file, if it encounters word “true” or “false” it treats them as boolean. In addition to that, synonyms of “true” and “false” like “yes”…… Continue reading Yaml parser feature PARSE_BOOLEAN_LIKE_WORDS_AS_STRINGS
Writing JSON Data using JsonWriter
This post explains how to write json data to a file using JsonWriter. With JsonWriter we dont need to build the entire object in memory. The code explains how to write the below json data [ { “id”: 1, “text”: “text1”, “array”: null }, { “id”: 2, “text”: “text2!”, “array”: [ 50.454722, -104.606667 ] }…… Continue reading Writing JSON Data using JsonWriter
Creating a YAML file
The below post explains how to write YAML data to file using YAMLGenerator. YAMLGenerator writes the data to a file in streaming way, helping the developer using the api to avoid creating an object representation of the entire data. We can get an instance of YAMLGenerator with the help of an instance of YAMLFactory as…… Continue reading Creating a YAML file
Printing json data in a formatted way
This post explains how to print json data in a properly formatted way, whether the destination is console, file etc. For example when the below code prints the json data to a file, the output will be as shown below Initial Code package package11; import java.io.File; import java.io.FileWriter; import java.io.IOException; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerator; public…… Continue reading Printing json data in a formatted way
Getting JsonGenerator settings
This post explains how to get JsonGenerator settings. JsonGenerator class obtained from JsonFactory is responsible for writing json data as a stream instead of constructing an entire object model in memory and then writing to destination. The list of settings that can be turned on or off are present in an enumeration JsonGenerator.Feature. The below…… Continue reading Getting JsonGenerator settings
Getting JsonFactory settings
This post explains how to get JsonFactory settings. The JsonFactory class is thread safe and responsible for creating instances of writer and reader. Creating an instance of JsonFactory is an light weight operation. The list of settings that can be turned on or off are present in an enumeration JsonFactory.Feature. The below code shows how…… Continue reading Getting JsonFactory settings
Writing json data using Jackson JsonGenerator
The below post explains how to write json data to file using JsonGenerator. JsonGenerator writes the data to a file in streaming way, helping the developer using the api to avoid creating an object representation of the data. We can get an instance of JsonGenerator with the help of an instance of JsonFactory as shown…… Continue reading Writing json data using Jackson JsonGenerator
Retrieving JsonParser Settings
This post explains how to get json parser default settings. import java.io.File; import java.io.IOException; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonParser.Feature; public class ProcessingDemo2 { public static void main(String[] args) throws JsonParseException, IOException { File file = new File(“jsondata.json”); JsonFactory jsonFactory = new JsonFactory(); JsonParser jsonParser = jsonFactory.createParser(file); for(Feature feature : Feature.values()) { System.out.println(feature.name()…… Continue reading Retrieving JsonParser Settings
Streaming two json files in an order using JsonParserSequence
This post explains how to stream two files in a particular order Main Class import java.io.File; import java.io.IOException; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.util.JsonParserSequence; public class ProcessingDemo3 { public static void main(String[] args) throws JsonParseException, IOException { File file1 = new File(“jsondata.json”); File file2 = new File(“jsondata1.json”); JsonFactory jsonFactory = new…… Continue reading Streaming two json files in an order using JsonParserSequence