private static JsonNode toJsonValue(Object value, ObjectMapper mapper) {
    if (value == null) {
      return mapper.getNodeFactory().nullNode();
    }

    return mapper.convertValue(value, JsonNode.class);
  }
Write usually simple (scalar) value (string, number, boolean or null) to json output.
In case of complex objects delegates to jackson serialization.

@param value JSON value to write
criteria/elasticsearch/src/org/immutables/criteria/elasticsearch/QueryBuilders.java