Posted In: GSON, JSON

GSON – How to exclude fields during serialization/toJSON using JsonSerializer

Use com.google.gson.JsonSerializer to add only required fields Output maiingAddress is excluded

Read More

Tags: Tags:

by , on February 22nd, 2018

Posted In: GSON, JSON

GSON – How to exclude fields during serialization/toJSON

Use com.google.gson.annotations.Expose to exclude Output maiingAddress is excluded

Read More

Tags:

by , on February 22nd, 2018

Posted In: GSON, JSON

GSON – Resolving Expected BEGIN_OBJECT but was BEGIN_ARRAY exception

Code will throw following error com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 13 path $.student at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224) To resolve either POJO or input JSON needs to be corrected

Read More

Tags:

by , on February 22nd, 2018

Posted In: GSON, JSON

GSON TypeAdapter – How to process large JSON file

I have successfully tried this code with 90K records. This is useful in following scenarios When it is impossible or undesirable to load the entire object model into memory. This is most relevant on mobile platforms where memory is limited. When it is necessary to read or write a document before it is completely available. […]

Read More

Tags: Tags:

by , on February 21st, 2018

Posted In: Jackson 2X, JSON, XML

How to convert POJO to XML using Jackson library

Maven Dependency POJO Jackson 2X XmlMapper Result

Read More

Tags:

by , on September 1st, 2017

Posted In: Jackson 2X, JSON, XML

How to convert XML to POJO using Jackson library

Maven Dependency POJO Jackson 2X XmlMapper Result

Read More

Tags:

by , on September 1st, 2017

Posted In: Jackson 2X, JSON

Converting CSV to JSON using Jackson library

Maven Jackson 2X Classes used

Read More

Tags: Tags:

by , on August 31st, 2017

Posted In: JSON, XML

How to convert XML to JSON using org.json.XML

Result

Read More

Tags: Tags:

by , on August 31st, 2017

Posted In: Java Core, JSON

Converting JSON to CSV in Java using Arkni – json-to-csv

Download org.jsontocsv.parser.JSONFlattener from Arkni – json-to-csv package com.example.csv; import java.util.List; import java.util.Map; import org.jsontocsv.parser.JSONFlattener; import org.jsontocsv.writer.CSVWriter; import org.junit.Test; public class JsonToCsv2 { @Test public void jsontocsv() throws Exception { System.out.println(“jsontocsv started”); try { List flatJson = JSONFlattener .parseJson(jsonString()); CSVWriter.writeToFile(CSVWriter.getCSV(flatJson, “,”), “E:/files/outcsv1.csv”); } catch (Exception e) { e.printStackTrace(); } } private static String jsonString() { return […]

Read More

Tags: Tags:

by , on August 31st, 2017