Click here to Skip to main content
Click here to Skip to main content

Java Json Parser Online Tool

, 14 Feb 2014
Rate this:
Please Sign up or sign in to vote.
Java Json Parser Online Tool

Introduction

Now you don't need to write Json parser classes in Java. There is an online JSON parser tool available which will create all required Java classes for you. So you can parse complex JSON within few seconds. Although it is very simple to use, I am explaining the steps below.

How to Use

Here are the steps to use this online tool:

  1. Following is the JSON string that needs to be parsed. It returns a list of students.
    {
        "resultCode": 200,
        "message": "Students Fetched Successfully",
        "result": 1,
        "students": [
            {
                "name": "Gaurav Dixit",
                "rollNumber": null,
                "regId": 1001,
                "photo": "http://www.vims.edu/people/jones_rm/photo/Randy%20Cropped%20Small.jpg",
                "class": "12th"
            },
            {
                "name": "Sanjay Dixit",
                "rollNumber": 88,
                "regId": 1002,
                "photo": "http://www.clackamas.edu/uploadedImages/Utility%20Student%20Showcase100x100.JPG",
                "class": "11th"
            }
        ]
    } 
  2. Sometimes, there are some JSON keys with null values. For example, the above JSON rollNumber key. So you must assign a custom value to this key. Let us assign it 10.
  3. {
        "resultCode": 200,
        "message": "Students Fetched Successfully",
        "result": 1,
        "students": [
            {
                "name": "Gaurav Dixit",
                "rollNumber": 10,
                "regId": 1001,
                "photo": "http://www.vims.edu/people/jones_rm/photo/Randy%20Cropped%20Small.jpg",
                "class": "12th"
            },
            {
                "name": "Sanjay Dixit",
                "rollNumber": 88,
                "regId": 1002,
                "photo": "http://www.clackamas.edu/uploadedImages/Utility%20Student%20Showcase100x100.JPG",
                "class": "11th"
            }
        ]
    }  
  4. If there are some blank JSON Arrays in JSON, they add at least one value. For example, if "students":[] then you should add one student JSON object in it.
  5. It is recommended that you keep only one object in JSON Array type objects. It will speed up the tool and also you don't need to search for null and blank JSON arrays in the JSON. For example, in the above JSON, we can remove the second object in students Array:
    1. {
          "resultCode": 200,
          "message": "Students Fetched Successfully",
          "result": 1,
          "students": [
              {
                  "name": "Gaurav Dixit",
                  "rollNumber": null,
                  "regId": 1001,
                  "photo": "http://www.vims.edu/people/jones_rm/photo/Randy%20Cropped%20Small.jpg",
                  "class": "12th"
              }
              
          ]
      }  
  6. Now click Parser Tool and fill the form as below. Please don't forget to choose radio button Java:

  7. Now click submit button and wait for a second server to send you the zip file and save it. Extract the zip, all bean classes and parser class in the folder. Copy them into your Android project and enjoy.

Important Points

  1. If there are JSON Array objects in the JSON string, please make sure those have at least one value in it.
  2. It is recommended to keep only one object in a JSON array. Although the tool will work with any type of JSON, it is for best results.
  3. Assign a fake value to the keys having null value.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Sukhpal Singh JNU Jaipur
Software Developer (Senior)
India India
B. Tech in Computer Science. Rich experience in different types of applications mainly Mobile and Web Development.
 
Worked on J2SE, J2EE, C, C++, C#, Objective C, Ruby, ASP.NET, Visual Basic, HTML, Java Script, CSS, Android, BlackBerry, iOS, Rhomobile and PhoneGap.

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 14 Feb 2014
Article Copyright 2014 by Sukhpal Singh JNU Jaipur
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid