code: protected static void convertMapToKeysItems(final JsonObject<String, Object> map)
      {
          if (!map.containsKey("@keys") && !map.isReference())
          {
              final Object[] keys = new Object[map.size()];
              final Object[] values = new Object[map.size()];
              int i = 0;
  
              for (Object e : map.entrySet())
              {
                  final Map.Entry entry = (Map.Entry) e;
                  keys[i] = entry.getKey();
                  values[i] = entry.getValue();
                  i++;
              }
              String saveType = map.getType();
              map.clear();
              map.setType(saveType);
              map.put("@keys", keys);
              map.put("@items", values);
          }
      }
docs: Convert an input JsonObject map (known to represent a Map.class or derivative) that has regular keys and values
  to have its keys placed into @keys, and its values placed into @items.
  
  @param map Map to convert