31-08-2017, 09:04 AM
Writing a Java application (see Android) that consumes a JSON API usually involves assigning JSON objects to Java classes for use in the software. This is a tedious and repetitive task to say the least. When something is tedious and repetitive, it is often an excellent candidate for software automation.
Almost all mobile applications and many web and desktop applications use some type of API to communicate data between remote servers. These days, the preferred data format for such communication is JavaScript Object Notation, or JSON. JSON is desirable for this purpose for several reasons: it is easy to read and write for humans; is well supported in most programming languages; is native JavaScript which makes it very convenient for web development.
When writing a Java application that depends heavily on a JSON API, it is almost always necessary to deserialize the JSON data in native Java classes. The process is something like this:
1. Download all JSON responses for the API or consult the documentation
2. Analyze the structure of JSON objects and plot your Java classes
3. Manually create each Java class by carefully entering each private property name and data type to match the JSON properties of all objects
4. Create public getter and setter messages for each property on each object
Almost all mobile applications and many web and desktop applications use some type of API to communicate data between remote servers. These days, the preferred data format for such communication is JavaScript Object Notation, or JSON. JSON is desirable for this purpose for several reasons: it is easy to read and write for humans; is well supported in most programming languages; is native JavaScript which makes it very convenient for web development.
When writing a Java application that depends heavily on a JSON API, it is almost always necessary to deserialize the JSON data in native Java classes. The process is something like this:
1. Download all JSON responses for the API or consult the documentation
2. Analyze the structure of JSON objects and plot your Java classes
3. Manually create each Java class by carefully entering each private property name and data type to match the JSON properties of all objects
4. Create public getter and setter messages for each property on each object