I am currently working on an application that needs to create a mapping between document pdfs and corresponding JSON data files. The files are coming from a third party so I have no control over their format. I am currently taking the incoming json files and deserializing them into kotlin data classes. The next step is to take the list of Idoc objects produced by the deserialization and convert them into a data structure that allows for easy lookup. Given a student id, document imageCode, and owner type (obtained from the filename of a pdf) I need to lookup the Document.documentYear value. What would be the most efficient way to do this?
internal data class Idoc(@SerializedName("FileId") val fileId: String, @SerializedName("Student") val students: List<Student>)
internal data class Student(@SerializedName("Id") val id: String,
@SerializedName("SchoolId") val schoolId: String,
@SerializedName("Name") val name: String,
@SerializedName("Documents") val documents: List<Document>)
//Although owners is structured as a list, there will only ever be one Owner per Document
internal data class Document(
@SerializedName("Year") val documentYear: String,
@SerializedName("Code") val imageCode: String,
@SerializedName("DocumentOwner") val owners: List<DocumentOwner>,
)
internal data class DocumentOwner(@SerializedName("FirstName") val firstName: String,
@SerializedName("LastName") val lastName: String,
@SerializedName("OwnerType") val type: String