There is a debate in my company on whether we should use the JSON API specification or stick to plain JSON for developing APIs that will be consumed by mobile apps, mainly iOS and Android.
One argument for JSON API is that since everything is defined before hand, if new developers were to begin work on the API they should be able to find what they need fast. Another is that since most of the relationships can be bundled to a response, it can relieve server load.
One argument against JSON API is that it creates problems that didn't exist before. When using plain JSON there are attributes that hold relationships or objects of the same type e.g: If I where to have a novel with holds information on the author and publisher the plain JSON would be something like that:
{
author: {
name: "John",
lastname: "Appleseed",
id: 1
},
title: "Some great novel",
publisher: {
name: "Something"
}
}
and then, on Android I could create a class to serialise the JSON. The class would be something like that
class Novel {
String title;
Author author;
Publisher publisher;
}
class Author {
String name;
String lastname;
int id;
}
class Publisher {
String name;
}
and then Retrofit would parse the response and return a Novel POJO.
In Swift, we could use SwiftyJSON and create some similar structs or classes with the only difference being that I would have to write some extra boilerplate code to set the values of the class. This seems like a straightforward approach.
But when using the JSON API implementation will become much more complex and unreadable.
Regarding the argument that it relieves server load since it can bundle most relationships and return them with the response you can achieve that with plain JSON as in the example above.
I could use some insight on whether it is a good choice to use JSON API with statically typed languages such as Java or Swift