Answer the question
In order to leave comments, you need to log in
Which articles to read for implementing JSON parsing in Java?
Recommend good articles in Russian (more or less from English, but when I read, I don’t understand most of it), which explains how to parse JSON (by URL) in Java. I tried the json.org and gson libraries, but since I have little experience, I meet errors, or I just don’t know how instead of Object obj = parser.parse(new FileReader("c:\test.json")); make it parse from the URL. The option Object obj = parser.parse(new URL("url here"); doesn't work.
Answer the question
In order to leave comments, you need to log in
Flies separately, cutlets separately. First, download the data to a variable/file using the URL, then parse this data. Your json parser doesn't have to care where the data comes from - it has to parse it. When working with the url, don't forget about asynchrony.
Url is not yet a set stream. This is how it can work:
URL exampleUrl = new URL("example.com");
BufferedReader bufferReader = new BufferedReader( new InputStreamReader(exampleUrl.openStream()));
JsonParser parser = Json.createParser(bufferReader);
This is where the JSON is parsed.
www.androidhive.info/2012/05/how-to-connect-androi...
The code of the parser itself is produced at the very bottom.
To get a
List object params = new ArrayList(); // list of parameters, such as password and login
JSONObject json = jParser.makeHttpRequest(url_all_products, "GET", params);
To get a nested object product = json.getJSONObject()
To get a property of an object product.getInt("property name") or product.getString("property name")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question