top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How to analyse Json data from Url (JSON-API)?

+1 vote

Please help me with following -
1. Write a java program to get json data from URL
2. Perform mathematical operation in java after reading JSON from above URL and print result.for ex.result=10+5=15
3. Result should be dynamic and should change if change values in above URL.

posted Feb 5, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Will it solve by printing on consol or some other method.?please anyone can help me out..

1 Answer

0 votes

This link is not working, anyway I got the problem and providing the steps
1.Read the URL and get the JSON string something like

  public static JSONObject readJsonFromUrl(String url) throws IOException, JSONException {
    InputStream is = new URL(url).openStream();
    try {
      BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
      String jsonText = readAll(rd);
      JSONObject json = new JSONObject(jsonText);
      return json;
    } finally {

2.Decode the JSON string something like

JSONObject json = readJsonFromUrl("<Your URL>");

3.Rest is simple and leave it to you how you would solve it, just need to use opr1, opr2 and operator :)

answer Feb 5, 2016 by Salil Agrawal
Similar Questions
+2 votes

I have a requirement in which I will get data in CSV file. I have to create a JSON file for this data. Please suggest me how I can implement this in Informatica Power Centre.

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.