
Posted In: JSON
Convert json string to pretty print json output using JSON library
1. Example will use following Test data 2. Using GSON.toJson 3. Using Jackson 2X writerWithDefaultPrettyPrinter 4. Using Jackson 1X writerWithDefaultPrettyPrinter 5. Using org.json.JSONObject.toString(indent) from org.json library 6. Using net.sf.json.JSONObject.toString(indent) from net.sf.json-lib library 7. Output { “portfolio” : [ { “stock” : “Infosys”, “quantity” : “100”, “buy” : […]
Read MoreTags: GSON, Jackson 1X, Jackson 2X, JSON, net.sf.json.JSONObject, org.json.JSONObject

Posted In: JSON
Are escaping special characters in JSON string required?
Following tests with various libraries confirms that JSON library will handle special characters and there is no need to use StringEscapeUtilities.escapeHtml, StringEscapeUtilities.escapeXml or java.net.URLEncoder 1. Example will use following Test data 2. Using GSON 3. Using Jackson 2X 4. Using Jackson 1X 5. Using com.jsoniter.output.JsonStream from json iterator library […]
Read MoreTags: GSON, Jackson 1X, Jackson 2X, JSON, JsonIterator, net.sf.json.JSONObject

Posted In: JSON
How to parse JSON to POJO in Java
This example uses general JSONObject or Any object provided by library. To parse JSON to your own application POJO refere this. 1. Example will use following Test data 2. Using GSON 3. Using Jackson 2X 4. Using Jackson 1X 5. Using JsonIterator from json iterator library 6. Using […]
Read MoreTags: GSON, Jackson 1X, Jackson 2X, JSON, JsonIterator, net.sf.json.JSONObject

Posted In: JSON
How to parse JSON in Java – Without POJO
This example uses general JSONObject or Any object provided by library. To parse JSON to your own application POJO refer how-to-parse-json-to-pojo-in-java 1. Example will use following Test data 2. Using GSON 3. Using Jackson 2X 4. Using Jackson 1X 5. Using JsonIterator from json iterator library 6. Using […]
Read MoreTags: GSON, Jackson 1X, Jackson 2X, JSON, JsonIterator, net.sf.json.JSONObject

Posted In: JSON
How to convert ArrayList to JSON object in Java
1. Example will use following Test data 2. Using GSON 3. Using Jackson 2X 4. Using Jackson 1X 5. Using com.jsoniter.output.JsonStream from json iterator library 6. Using net.sf.json.JSONArrayfrom net.sf.json-lib library 7. Using javax.json.JsonArray, javax.json.JsonArrayBuilder from javax.json library 8. Using org.json.JSONArray from org.json library 9. Output [“val1″,”val2″,”val3″,”val4″,”val5”] […]
Read MoreTags: ArrayList, GSON, Jackson 1X, Jackson 2X, javax.json, JSON, Json parsing of json array, JsonIterator, net.sf.json.JSONObject, org.json

Posted In: JSON
How to convert hashmap to JSON object in Java
1. Example will use following Test data 2. Using GSON 3. Using Jackson 2X 4. Using Jackson 1X 5. Using com.jsoniter.output.JsonStream from json iterator library 6. Using net.sf.json.JSONObject from net.sf.json-lib library 7. Using javax.json.JsonObject, javax.json.JsonObjectBuilder from javax.json library 8. Using org.json.JSONObject from org.json library 9. Output […]
Read MoreTags: GSON, Hashmap, Jackson 1X, Jackson 2X, javax.json, JSON, Json parsing of json array, JsonIterator, net.sf.json.JSONObject, org.json
- Apache (13)
- Build Tools (2)
- Gradle (2)
- Caching (1)
- cpanel (1)
- cURL (1)
- Database (7)
- Hibernate (5)
- Java Core (38)
- Java Script (15)
- Bootstrap (1)
- File Upload (7)
- jQuery (3)
- React (3)
- JEE (13)
- JSON (41)
- GSON (13)
- Jackson 1X (1)
- Jackson 2X (12)
- jsoniter (1)
- Logging (2)
- Apache Commons Logging (1)
- Apache Log4J (1)
- Logback (1)
- SLF4J (1)
- MongoDB (1)
- OS (1)
- Linux (1)
- Security (5)
- Server (4)
- Tomcat (4)
- Service (2)
- Micro (2)
- Spring (46)
- Pattern (2)
- Spring Boot (20)
- Spring Data (4)
- Spring MVC (8)
- Spring REST (13)
- Spring Security (7)
- Testing (11)
- XML (5)
- JDOM XML Parser (1)