ObjectiveIf you are an Android developer, you know that parsing JSON response is not rocket science but if there are lot of elements, coding your JSON Parsing class makes your life literally hell !
Consider this JSON Response from Yahoo as an example.
Believe me, I know its pain to look at that crap response !! bear with it fNow, what if I ask you to parse this response in 5 mins? You'll say over my dead body - this is not possible !
But what if I tell you that I can parse this response in around 10 seconds with the tool we have developed - would you be interested in knowing about it ? if so, read further. @ TheAppGuruz We have done manual JSON parsing for like thousands of times and have wasted valuable time (sigh!) over this brainless thing.
NO MORE !!
This tool can parse any JSON response in a jiffy - you have to simply follow the 3 Golden Steps:
After opening the tool you have downloaded (its an executable jar file - and if you are Java/ Android developer, you know what it is. If you don't know, google it)
1) Put JSON Parser class in your Android project (you'll get the code for that class by clicking on 'Get JSON Parser Class Code' Button on the tool) - dont change this code if you take my advice (aah...do whatever you want to do - but after monkeying around don't complain that this damn tool doesn't work)
2) Put your JSON URL/ JSON Response you want to parse
Note: Use post method in the same way as get method
e.g. theappguruz.com/login.php?username=tejas&pass=mypass (this link doesnt work - its just an example)
3) Click Generate Code button, and Voilà ! You get your JSON parsing class code Practically, the guide is over here but if you are interested in learning everything visually - follow the guidelines given below:
Step 1 Create an Android Project
Step 2 JSONParser.java file
Put JSONParser.java class in your Android Project. If you are running this tool for the first and if you dont have the code for "JSONParser.java" class, you can click on Get JSON Parser Class Code button and it will generate the code.
Next, You'll have to copy that code and paste it into your Android Project
This is how your "JSONParser.java" class should look
Step 3 JSON Response
Put your JSON Response URL (You can put your JSON Response Text too as other option)
Check this JSON Response from Yahoo I have used in this example pretty long (and pretty bad too) response
Note: You can use this tool to view formatted JSON response (see the screenshot below).
Step 4 Generate Code
Generate and Copy Code
Press the Red "Generate Code" Button (if you want to print your parsed response on console - check the "with log" checkbox)
Copy the generated code
I have created a project with an Activity called 'MainActivity' - delete the code from this Activity
Change the name of your class from 'Your Activity' to 'Main Activity' (or whatever your activity name you wan to put)
After you are done with everything, you will see few errors - you have to manage your imports (Ctrl + Shift + O on Windows/ Linux and Command + Shift + O on Mac) After that to format your code (Ctrl + Shift + F on Windows/ Linux and Command + Shift + F on Mac) and you are done !! Check the final output in screenshot below
This tool saves you hell amount of time (takes less than 10 seconds to generate code) and you wont have to smash your head on wall for those lengthy responses. If you have any questions or concerns, feel free to put a comment on this post. And if you like this tool, feel free to share it with your friends :) Happy Coding !! For Reference:
DOWNLOAD JSON PARSING TOOL WITH SAMPLE PROJECT
If you still have got any doubt related to JSON Parsing tool comment your query below we will try to sort it out.
Got an Idea of Android App Development? What are you still waiting for? Contact us now and see the Idea live soon. Our company has been named as one of the best Android App Development Company in India.
An entrepreneur who has founded 2 flourishing software firms in 7 years, Tejas is keen to understand everything about gaming - from the business dynamics to awesome designs to gamer psychology. As the founder-CEO of a company that has released some very successful games, he knows a thing or two about gaming. He shares his knowledge through blogs and talks that he gets invited to.