private String constructPath(final JsonMappingException e) {
    final StringBuilder builder = new StringBuilder();

    boolean lastIndex = false;

    for (final JsonMappingException.Reference reference : e.getPath()) {
      if (reference.getIndex() >= 0) {
        builder.append("[" + reference.getIndex() + "]");
        lastIndex = true;
        continue;
      }

      if (builder.length() > 0 && !lastIndex) {
        builder.append(".");
      }

      builder.append(reference.getFieldName());
      lastIndex = false;
    }

    return builder.toString();
  }
Exemple #2
0
  private String buildPath(List<JsonMappingException.Reference> refs) {
    StringBuilder sb = new StringBuilder();
    JsonMappingException.Reference prev = null;
    for (JsonMappingException.Reference ref : refs) {
      if (prev != null && ref.getFieldName() != null) {
        sb.append('.');
      }

      if (ref.getFieldName() != null) {
        sb.append(ref.getFieldName());
      } else {
        sb.append("[").append(ref.getIndex()).append("]");
      }
      prev = ref;
    }
    return sb.toString();
  }