I have a map of, lets say, day of week vs the amount of rain, as an example. Looks like:
1 -> 5"
2 -> 12"
3 -> 0"
4 -> 0"
5 -> 5"
6 -> 7"
7 -> 12"
I want to organize this in a sorted way:
0" -> 3
0" -> 4
5" -> 1
5" -> 5
7" -> 6
12" -> 2
12" -> 7
Also, want to store this to a JSON file, and have another program read this JSON back. The 2 programs may not have shared classes. So rather than write custom code on each side, if it is possible, I want to try and solve this problem using the standard classes from Java.
Would this be possible to do?
One solution I can think of of the top of my head is to write 2 arrays, the first one with the " of rain, and the second one which would be the index of the weekday. Thus looking like:
{
"inchRain": [
0, 0, 5, 5, 7, 12, 12
],
"arrIndex": [
3, 4, 1, 5, 6, 2, 7
]
}
Any other ideas anyone can think of? Thanks,