Take a snapshot of the current map first. Then serialize each field using Gson. The Gson library cannot perfectly preserve the type for the map, so I serialize them individually. We can change the map we use to become Map<String, List<List<Byte>>, but the type inference would still not be perfect.