0

i'm working on a API, and i want to take the json data that is display in an adress like this : https://api.empireavenue.com/profile/info/?apikey=YOURAPIKEY&username=TICKER&password=PASSWORD

and take this data to display it on my app . Thanks.

2
  • 2
    Are you asking how to parse the data or how to get the json data to your application?
    – prolink007
    Nov 8, 2010 at 18:14
  • i know how to parse, but the data i want to parse is created on a webpage, and the only wait to get this data is via url.
    – Tsunaze
    Nov 8, 2010 at 18:39

1 Answer 1

0

The input to the parseJson method should be whatever you get back from the HTTP request. This also assumes the format is something like:

{"rootKey":{"intVal":1}}

You will have to modify the order in which you query objects depending on the structure.


private static final ROOT_JSON_KEY = "rootKey";
private static final INT_VALUE_NAME = "intVal"; 

public void parseJson(String webServiceResponse) {

    JSONObject json = new JSONObject(webServiceResponse);
    JSONObject rootObject = json.getJSONObject(ROOT_KEY);
    int intValues = rootObject.getInt(INT_VALUE_NAME);

}

EDIT: Sorry, stupid coding error.

2
  • But what is the webserviceresponse ? Is it a inputstream or a httpentity or ?
    – Tsunaze
    Nov 9, 2010 at 6:58
  • and do you know how to do it with a JsonArray ?
    – Tsunaze
    Nov 11, 2010 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.