public static String getSerializedJSON(List<SearchResult> searchResults) {
    ArrayNode resultArray = JsonNodeFactory.instance.arrayNode();
    for (SearchResult result : searchResults) {
      ObjectNode resultNode = JsonNodeFactory.instance.objectNode();
      resultNode.put("metric", result.getMetricName());

      String unit = result.getUnit();
      if (unit != null) {
        // Preaggreated metrics do not have units. Do not want to return null units in query
        // results.
        resultNode.put("unit", unit);
      }

      // get enum values and add if applicable
      List<String> enumValues = result.getEnumValues();
      if (enumValues != null) {
        // sort for consistent result ordering
        Collections.sort(enumValues);
        ArrayNode enumValuesArray = JsonNodeFactory.instance.arrayNode();
        for (String val : enumValues) {
          enumValuesArray.add(val);
        }
        resultNode.put("enum_values", enumValuesArray);
      }

      resultArray.add(resultNode);
    }
    return resultArray.toString();
  }
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  @Path("/class")
  public String getClasses() {
    ArrayNode noClasses = JsonNodeFactory.instance.arrayNode();

    for (Clazz clazz : LomBusinessFacade.getInstance().getAllClasses()) {
      noClasses.add(clazz.getJson());
    }

    return noClasses.toString();
  }
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  @Path("/attribute")
  public String getAttributes() {
    ArrayNode noAttributes = JsonNodeFactory.instance.arrayNode();

    for (Attribute attribute : LomBusinessFacade.getInstance().getAllAttributes()) {
      noAttributes.add(attribute.getJson());
    }

    return noAttributes.toString();
  }
 @GET
 @Produces(MediaType.APPLICATION_JSON)
 @Path("/class/{fullName}/attributes")
 public String getAttributesFromClass(@PathParam("fullName") String fullName) {
   Clazz clazz = LomBusinessFacade.getInstance().getClass(fullName);
   ArrayNode attributesNode = JsonNodeFactory.instance.arrayNode();
   if (clazz != null) {
     List<Attribute> attributes =
         LomBusinessFacade.getInstance().getAttributesByClassID(clazz.getId());
     for (Attribute attribute : attributes) {
       attributesNode.add(attribute.getJson());
     }
   }
   return attributesNode.toString();
 }