Home » Core Java » json

json

Read JSON From a URL Example Using Data Pipeline

I have a problem. I want to read JSON from a URL. Naturally, like anybody else, I googled for some solutions. There were a lot of solutions shared in Stack Overflow and other sites. I tried some of them but I’d like to share the one where I used the Data Pipeline Java library. 1. Tools and Prerequisites Data Pipeline ...

Read More »

Java JSON parser Example

JSON is a simply text format that facilitates reading and writing. It is a widely used data-interchange language because its parsing and its generation is easy for machines. In Java language there are some ways for JSON processing. In this example we are going to use a common Java toolkit for JSON – JSON.simple – and we will find out ...

Read More »

JSON.Simple Example to read and write JSON in Java

In this example we are going to see a very nice JSON framwork, JSON.simple. In this tutorial we are going to see how to read and write JSON to file using this framework, and you will notice yourself how simple :) it really is. 1. JSON.simple library and dependencies If your are using Maven to build your project, you just ...

Read More »

Enable Pretty Print JSON Output using Jackson example

As you might have noticed in the previous JSON tutorials, the output of the programs is not properly aligned, which makes it hard to read. For this demonstration we are going to use the Student class from this example.             Student.java: package com.javacodegeeks.java.core; public class Student { private int id; private String firstName; private String ...

Read More »

Jackson Streaming API to read and write JSON example

Jackson project has implemented a very useful Streaming API which is also called incremental mode. This is the most efficient way to process JSON content. It has the lowest memory and processing overhead, and can often match performance of many binary data formats available on Java platform. It’s a bit tricky to use though because you have to handle JSON ...

Read More »

Jackson Tree Model example

In this example we are going to see how to use Jackson Tree Model. This model is very similar in many ways with the DOM representation. We are going to see how to create the tree model and update the JSON object with new values.                   Here is the file we are ...

Read More »

Convert Java Map To / From JSON using Jackson example

With this example we are going to see how to convert a java.util.Map Object to /from JSON representation using the Jackson parser. Converting Map to / from JSON comes naturally because they have a pretty similar representation and usage. Take a look at the precious Jackson tutorial where we showed how to convert a user defined Java Object to / ...

Read More »

Convert Java Object To / From JSON using Jackson example

In this example we are going to see how to conver a Java Object to JSON representation using Jackson. Jackson in a high performance JSON parser and processor java project. 1. Jackson Library The complete Jackson library consists of 6 jar files that are used for many diffident operation. In this example we are going to need just one, mapper-asl.jar. ...

Read More »

JSON parsing with Gson

This is an example of JSON parsing on Android with Gson. Google Gson is a Java library that can be used to convert Java Objects into their JSON representation. In order to parse JSON with Gson, follow these steps: Create a class that extends Activity (here called JsonParsingActivity) Create an instance of the Gson class Use the DefaultHttpClient to retrieve ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns