How to Read and Write JSON using json-simple library

21 Flares Twitter 0 Facebook 2 Google+ 19 LinkedIn 0 Filament.io 21 Flares ×

JSON.simple is a simple Java toolkit for JSON. You can use JSON.simple to encode or decode JSON text. It is in Full compliance with JSON specification (RFC4627). Its main features are

  • Simple to Use
  • Good performance ( See Results here)
  • Supports Streaming output
  • No dependence on external libraries
  • Fully complaint with JDK 1.2

First you need to Download the library and put it in your project classpath. If you use Maven you can add the following dependency

Write JSON – Example (json.simple)

Output

Read JSON – Example (json.simple)

References

Google JSON-Simple Project

  • sagar

    Can u please provide example to compare two diffrent JSON files using JAVA

  • Nice aarticle. we can also use gson library also visit json tutorial . here you can see more json examples with jackson and gson library.