Академический Документы
Профессиональный Документы
Культура Документы
(http://www.smlcodes.com/)
For dealing with JSON Parsing in java we have to use JSON.simple (https://code.google.com/archive/p/json-simple/). JSON.simple is a simple Java
toolkit for JSON. You can use JSON.simple to encode or decode JSON text.
Features
Full compliance with JSON speci䁾�cation (http://www.ietf.org/rfc/rfc4627.txt) (RFC4627) and reliable (see compliance testing)
Provides multiple functionalities such as encode, decode/parse and escape JSON text while keeping the library lightweight
Flexible, simple and easy to use by reusing Map and List interfaces
Supports streaming output of JSON text
Stoppable SAX-like interface for streaming input of JSON text
Heap based parser
High performance (see performance testing)
No dependency on external libraries
Both of the source code and the binary are JDK1.2 compatible
JSON Data
http://www.smlcodes.com/java/jsonparsingusingjava/ 1/6
2/25/2017 JSON Parsing using Java – Small Codes
1 {
2 "website":"smlcodes.com",
3 "year":2016,
4 "articles":[
5 "Java",
6 "JavaScript",
7 "Servers",
8 "Tools",
9 "DevOps"
10 ]
11 }
For doing so, we have to use below classes. Just know something about those classes.
JSONParser : we use parse(json䁾�le) method to parse the JSON 䁾�le. It will parse the JSON 䁾�le and arranges the data into <key,value> pairs
Steps:
1.Create JSONParser object, parse the json 䁾�le and store values into Object type.
2.Convert Object type values into JSONObject type values
http://www.smlcodes.com/java/jsonparsingusingjava/ 2/6
2/25/2017 JSON Parsing using Java – Small Codes
4.if get(“key”) returns JSONArray , use iterator() method to get array values
Ref:
https://www.mkyong.com/java/json-simple-example-read-and-write-json/ (https://www.mkyong.com/java/json-simple-example-read-and-write-json/)
https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple/1.1.1 (https://mvnrepository.com/artifact/com.googlecode.json-
simple/json-simple/1.1.1)
http://central.maven.org/maven2/com/googlecode/json-simple/json-simple/ (http://central.maven.org/maven2/com/googlecode/json-simple/json-
simple/)
(http://www.smlcodes.com/java/json-parsing-using-java/?share=facebook&nb=1)
2
(http://www.smlcodes.com/java/json-parsing-using-java/?share=tumblr&nb=1)
(http://www.smlcodes.com/java/json-parsing-using-java/?share=email&nb=1)
(whatsapp://send?text=JSON%20Parsing%20using%20Java http%3A%2F%2Fwww.smlcodes.com%2Fjava%2Fjson-parsing-using-java%2F)
(http://www.smlcodes.com/java/json-parsing-using-java/#print) (http://www.smlcodes.com/java/json-parsing-using-java/?share=linkedin&nb=1)
1
(http://www.smlcodes.com/java/json-parsing-using-java/?share=twitter&nb=1)
Like this:
Loading...
http://www.smlcodes.com/java/jsonparsingusingjava/ 3/6
2/25/2017 JSON Parsing using Java – Small Codes
Related
Leave a Reply
Enter your comment here...
Search …
Recent Posts
MongoDB Tutorial for Java Developers (http://www.smlcodes.com/tutorials/mongodb-tutorial-java-developers/)
Archives
February 2017 (http://www.smlcodes.com/2017/02/)
http://www.smlcodes.com/java/jsonparsingusingjava/ 4/6
2/25/2017 JSON Parsing using Java – Small Codes
Categories
All Posts (http://www.smlcodes.com/category/all-posts/)
Books (http://www.smlcodes.com/category/more/books/)
Databases (http://www.smlcodes.com/category/tools/databases/)
DevOps (http://www.smlcodes.com/category/tools/devops/)
Examples (http://www.smlcodes.com/category/example/)
HTML (http://www.smlcodes.com/category/web-development/html/)
jar (http://www.smlcodes.com/category/more/jar/)
Java (http://www.smlcodes.com/category/java/)
JDBC (http://www.smlcodes.com/category/java/jdbc/)
JSON (http://www.smlcodes.com/category/web-development/json/)
jsoup (http://www.smlcodes.com/category/java/jsoup/)
JSP (http://www.smlcodes.com/category/java/jsp/)
More.. (http://www.smlcodes.com/category/more/)
PHP (http://www.smlcodes.com/category/web-development/php/)
Servers (http://www.smlcodes.com/category/tools/servers/)
Servlets (http://www.smlcodes.com/category/java/servlets/)
Struts (http://www.smlcodes.com/category/java/struts/)
Tools (http://www.smlcodes.com/category/tools/)
Tutorials (http://www.smlcodes.com/category/tutorials/)
http://www.smlcodes.com/java/jsonparsingusingjava/ 5/6
2/25/2017 JSON Parsing using Java – Small Codes
wordpress (http://www.smlcodes.com/category/web-development/wordpress/)
XML (http://www.smlcodes.com/category/web-development/xml/)
Pages
About (http://www.smlcodes.com/about/)
Compiler (http://www.smlcodes.com/compiler/)
Contact US (http://www.smlcodes.com/contact/)
Posts (http://www.smlcodes.com/posts/)
Tutorials (http://www.smlcodes.com/tutorials/)
Search …
Archives
Meta
Log in (http://www.smlcodes.com/wp-login.php)
http://www.smlcodes.com/java/jsonparsingusingjava/ 6/6