How to convert a JSON into a generic class

0

In a project with several client-server applications, I have a series of configuration files in JSON, which contain the connection port, host, and so on. For each application, the information in JSON is different:

configCache.json

{
    "port": "1234",
    "managerServerHost": "127.0.0.1",
    "managerServerPort": "1235",
    "cacheTimeout": "10000"
}

configSGBD.json

{
    "port": "1235",
    "studentServerHost": "127.0.0.1",
    "studentServerPort": "1236",
    "classServerHost": "127.0.0.1",
    "classServerPort": "1237"
}

configAlunos.json

{
   "port":"1236",
   "datafile":"student.data"
}

When running these applications, I need to get this JSON configuration information from each so I can port the Socket, etc. I was suggested using a single generic class to convert each JSON and get the information I need in each application. But I did not quite understand how generic classes work and how to use it in my problem. Someone willing to help ??

    
asked by anonymous 22.04.2018 / 21:37

0 answers