• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSON in Java

 
Soumya Maitra
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all and gurus

I am really new to Java world. Just joined the forum 2 min back.
Basically I come form Mac iOS development expanding my skill sets to Java/Android domain also.
I dont know whether this is the correct place in the forum to post my question or not let me try mine.

I am writing a JSON service that will parse JSON and return me a JSON object or an array whatever possible.
Can any one guide me to the correct way to it?

I did some R&D making it up to a successful call to Network as..................
Can you look at if error handling and garbage collection ( in method finalize () & clearGarbage() ) is alright?
Please guide




Regards
Soumya
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need not worry about garbage collection, but yes you should close all the resources which you open like FileReaders, network connections and so on. And dont rely on finalizers to do your garbage collection activity.

Then in your code you are not doing anything JSONish, I just see you are obtaining some data from a URL. For reading JSON or creating JSON have a look at GSON library. You would have to download the JAR and then add it to your classpath and use the APIs therein to parse/create JSON.
 
Soumya Maitra
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mohamed Sanaulla,

It was really appreciable that you come across to solve my problem .

I will try your solution and revert.
Mohamed Sanaulla wrote: For reading JSON or creating JSON have a look at GSON library. You would have to download the JAR and then add it to your classpath and use the APIs therein to parse/create JSON.


Thanks anyway.

Regards
Soumya
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic