Не может построить экземпляр com.response.dto.rootdto (хотя по крайней мере один создатель. ('Meta')
at [источник: (String) "Meta": [{"DimensionName": "Версия", "DimensionId": "3B4860B9-B215-4192-BD7A-A76F377FC465", Dimensi ontype ":" обычный "," псевдоним ":" c0 "," attributeId ":" 211d5-d91f-40ec-9668-20e0da2ae7b3 "," attributeName ":" Версия Имя "," attributeKey ":" versionKey "; Line: 1, столбец: 1] < /p>
Это то, на что выглядит моя строка json (но с excape chars in eclipse): < /p>
{" Meta ": [{" DimensionName ":" Версия ", "DimensionId":"3b4860b9-b215-4192-bd7a-a76f377fc465, "DimensionType":"Regular","Alias":"C0","AttributeId":"211b33d5-d91f-40ec-9668-20e0da2ae7b3","AttributeName":"Version Имя "," attributeKey ":" versionKey "}]}.
Код: Выделить всё
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class RootDTO
{
@JsonProperty("Meta")
private List Meta;
}
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class MetaDTO
{
@JsonProperty("DimensionName")
private String DimensionName;
@JsonProperty("AttributeId")
private String AttributeId;
@JsonProperty("AttributeName")
private String AttributeName;
@JsonProperty("Name")
private String Name;
@JsonProperty("Alias")
private String Alias;
}
< /code>
Это код, который дует при попытке прочитать значение: < /p>
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.readValue(jsonFormattedString, RootDTO.class));
Код: Выделить всё
String jsonFormattedString = responseEntity.getBody().substring(1, responseEntity.getBody().lastIndexOf("\"")).replaceAll("\\\\", "");
Подробнее здесь: https://stackoverflow.com/questions/683 ... ory-method