JSON.simple example – Read and write JSON

In this post,we will see how can we read and write JSON using json.simple.

Java JSON Tutorial Content:

JSON.simple, is a simple Java library for JSON processing, read and write JSON data and full compliance with JSON specification (RFC4627).

In this post,we will read and write JSON using JSON.simple.
Download JSON.simple jar from here.
Create a java project named “JSONSimpleExample”
Create a folder jars and paste downloaded jar json-simple-1.1.1.jar.
right click on project->Property->java build path->Add jars and then go to src->jars->json-simple-1.1.1.jar.

Click on ok.
Then you will see json-simple-1.1 jar added to your libraries and then click on ok

Write JSON to file:

Create a new class named “JSONSimpleWritingToFileExample.java” in src->org.arpit.java2blog

Run above program and you will get following output:

Read JSON to file:

Here we will read above created JSON file.
Create a new class named “JSONSimpleReadingFromFileExample.java” in src->org.arpit.java2blog

Run above program and you will get following output:

Project Structure:

Related Posts

  • Initialize empty array in java
    01 January

    Initialize empty array in java

    Table of ContentsIntroductionHow do you initialize an empty array in java?Using new Keyword with predefined Values and SizeUsing Anonymous Array Objects to initialize empty arrayUsing java.util.Scanner Class for user input with predefined size. Using java.io.BufferedReader to initialize array for user input with unknown sizeUsing fill() method of java.util.Arrays Class to initialize empty array 💡 Outline You […]

  • Python append to array
    30 December

    How to Append to Array in Python

    Table of ContentsWhat are the Different Array Implementations in Python?Python ListsPython ArraysPython Numpy ArraysAppend Element to List in pythonAppend to array in PythonAppend to NumPy array in pythonConclusion In python, we have three implementations of the array data structure. In this article, we will discuss those array implementations. After that, see how we can append […]

  • Convert dict to String in Python
    17 December

    Convert dict to string in python

    Table of ContentsHow to convert dict to string in python?Using str() method.Using the pickle module.Using the for loop.Using the json.dumps() method. In this post, we will see how to convert dict to String in Python. Python contains several data structures, and more often than not, there is a need for the conversion of one type […]

  • Python range float
    17 December

    Generate float range in Python [9 ways]

    Table of ContentsWhat is a floating-point number in Python?Why not use the simple and popular range() function?Python range float : How to generate floating-point numbers in Python?Using the numpy.linspace() method.Using the numpy.arange() method.Using list comprehension.Using generator comprehension.Using yield generator.Using a user-defined function.Using the itertools module and its functions.Using the map() function along with a lambda […]

  • Python array size
    17 December

    Python array size: get size of array in Python

    Table of ContentsPython array sizeWays to calculate the size of array in PythonUsing the len() functionUsing the numpy.size() attributeUsing the numpy.shape() attributeConclusion In this article, we will see how to get size of array in Python. Python array size An array stores a collection of similar elements in a contiguous memory location. In Python, we […]

  • Python callback function
    13 December

    Callback function in Python

    Table of ContentsWhat is Callback Function in Python?Applications of Callback Functions in PythonConclusion In python, functions are first-class objects. In other words, we can pass a function to a different function as an input argument. We can return a function from another function, and we can assign a function to a variable. In this article, […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.