Politics and War Wiki
Advertisement

Method 1

You'll have to connect to the API URL using Java.

You can do it natively like this:

https://docs.oracle.com/javase/tutorial/networking/urls/readingURL.html

or use a library like Unirest to do it easily.

Then you'll have to parse the JSON using external libraries like GSON or org.json. GSON is specifically suited for this purpose since it can convert JSON to custom java objects.

GSON short tutorial: http://tutorials.jenkov.com/java-json/gson.html

Tool for GSON custom object: http://www.jsonschema2pojo.org/

Some pre-made models for GSON by one of our community member : https://github.com/Devan-Kerman/DevTech-P-W

Method 2

Some of the community members have made wrappers for you to use easily. If you don't want to build your own wrapper, you can choose to use these:

pw4j: https://github.com/Adorable-SkullMaster/pw4j

Advertisement