The best way to handle JSON object in Aerospike

Hi rcritt,

Here is a technique to estimate the size of a value in bytes.

Create your list or map in java (JSON simple). Create an Aerospike Value from it, then call estimateSize() on the value.Here is an example:

List<String> places =  Arrays.asList("Buenos Aires", "Córdoba", "La Plata");
Map<String, Object> map = new HashMap<String, Object>(); 
map.put("cal", "this is a cat");
map.put("size", 1234L);
map.put("places", places);
Value mapValue = Value.get(map);
System.out.println("Size in bytes: " + mapValue.estimateSize());

I hope this helps.

Peter

1 Like