code: private static JSONObject toJSON(Mapping c) {
          JSONObject o = new JSONObject();
          o.put("offlineNodes", nodesToJSON(c.getOfflineNodes()));
          o.put("readyVMs", vmsToJSON(c.getReadyVMs()));
  
          JSONObject ons = new JSONObject();
          for (Node n : c.getOnlineNodes()) {
              JSONObject w = new JSONObject();
              w.put("runningVMs", vmsToJSON(c.getRunningVMs(n)));
              w.put("sleepingVMs", vmsToJSON(c.getSleepingVMs(n)));
              ons.put(Integer.toString(n.id()), w);
          }
          o.put("onlineNodes", ons);
          return o;
      }
docs: Serialise the mapping.
  
  @param c the mapping
  @return the resulting JSONObject