@Override public String asJSON() { return JSONFormatter.asJSON(this); }
/** * Converts a json representation back to an instance. * * @param json The string representation of the JSON. * @return An instance of this class. */ public static PubSubMessage fromJSON(String json) { return JSONFormatter.fromJSON(json, PubSubMessage.class); } }
@Override public String asJSON() { Map<String, Object> map = new HashMap<>(); map.put(ERROR_KEY, error); map.put(RESOLUTIONS_KEY, resolutions); return JSONFormatter.asJSON(map); }
@Override public String asJSON() { Map<String, Object> wrapper = new HashMap<>(); wrapper.put(META_KEY, meta.asMap()); wrapper.put(RECORDS_KEY, records.stream().map(Clip::asMap).collect(Collectors.toList())); return JSONFormatter.asJSON(wrapper); }
public static String zipToJSON(List<String> keys, List<Object> values) { Map<String, Object> map = new HashMap<>(); for (int i = 0; i < keys.size(); ++i) { map.put(keys.get(i), values.get(i)); } return JSONFormatter.asJSON(map); } }
public static String makeReturnInfo(String drpcID, String host, int port) { return JSONFormatter.asJSON(zipToJSON(asList("id", "host", "port"), asList(drpcID, host, port))); }