JACKSON / NOTES</>↗Jackson13 Feb 2022
In the following code snippet we will convert CSV into JSON string using Jackson JSON library. A comma-separated values is a delimited text, it uses comma to separate values. It starts with header on the first line, that will be the JSON key. Each subsequence lines is the data of the csv, which also contains […]
JSON-JAVA / NOTES</>↗JSON-Java12 Feb 2022
In the following code snippet you will see how to convert a CSV file into JSON file and vice versa. We use the JSON-Java library CDL class to convert between CSV and JSON format. The CDL class provide the toJSONArray(String) and toString(JSONArray) methods that allows us to do the conversion between data format. In the […]
JSON-JAVA / NOTES</>↗JSON-Java10 Feb 2022
In this example we convert CSV or CDL into JSON string. We are going to use the JSON-Java CDL (Comma Delimited Text) class. This class provides static methods that will convert a CSV into JSONArray or to convert a JSONArray into comma separated values. Here are what we do in the code snippet below: Create […]
GOOGLE GSON / NOTES</>↗Google Gson10 Feb 2022
In the following example you’ll see how to format JSON string using the Google Gson library. Here are the steps: We create a Map. Put a couple key-value pairs to it. We put a string, a LocalDate object and an array of String[]. Create a Gson object using the GsonBuilder. This allows us to configure […]
JSON-JAVA / NOTES</>↗JSON-Java07 Feb 2022
In JSON-Java we can make a pretty-printed JSON string by specifying an indentFactor to the JSONObject‘s toString() method. The indent factor is the number of spaces to add to each level of indentation. If indentFactor > 0 and the JSONObject has only one key, the JSON string will be printed a single line, and if […]
JSON-JAVA / NOTES</>↗JSON-Java07 Feb 2022
A JSONArray object represent an ordered sequence of values. We use the put() method to add or replace values in the JSONArray object. The value can be of the following types: Boolean, JSONArray, JSONObject, Number, String or the JSONObject.NULL object. Beside using the put() method we can also create and add data into JSONArray in […]