I'm making an Android App to manage a Unix computer remotely. The application also allows you to see real-time PC statistics (CPU temperature, CPU load, etc.). On the pc there is a Python server that through a socket sends a JSON string as a byte array to the app which contains the PC statistics, like this:
[123, 45, 67, 90, ...]
This is the contents of the byte array (I decoded it with a website):
{
"author": "Anton",
"type": "server info",
"date": "08/01/2021",
"content": "",
"opt": {
"cpu": {
"freq": [3866.041875, 1600.0, 3900.0],
"usage": [0.0, 0.0, 1.0, 2.0, 1.0, 1.0, 0.0, 2.0],
"load": [0.5, 0.63, 0.61]
},
"memory": {
"ram": [15.54, 12.01, 22.7, 2.85, 9.67]
},
"disks": {
"ssd": [219.1, 13.0, 194.9, 6.3],
"hdd": [0.0, 0.0, 0, 100.0]
},
"temps": {
"core-0": [32.0, 85.0, 105.0],
"core-1": [36.0, 85.0, 105.0],
"core-2": [37.0, 85.0, 105.0],
"core-3": [38.0, 85.0, 105.0]
}
},
"attached": null
}
How can I transform the byte array into a structure like a HashMap
or a JSON string, so that I can retrieve the PC statistics, and then view them in the App through ProgressiveBars?