Writing JSON files using JSON.simple

Just like XML, JSON is also a human-readable Data Interchange Format that is lightweight. It stands for JavaScript Object Notation. This is becoming a popular format generated and parsed by modern web applications. In this recipe, you will see how you can write JSON files.

Getting ready

In order to perform this recipe, we will require the following:

  1. Download json-simple-1.1.1.jar from https://code.google.com/archive/p/json-simple/downloads and include the JAR file as external library to your Eclipse project.

How to do it...

  1. Create a method named writeJson(String outFileName) that takes the name of the JSON file we will be generating as output with the JSON information in this recipe.
  2. Create a JSON object and use ...

Get Java Data Science Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.