com.fasterxml.jackson.databind.RuntimeJsonMappingException: нет конструктора int/Int-аргумента/фабричного метода для десериализации из числового значения

Я пытался прочитать объект JSON в свой POJO. Но получая следующую ошибку

      com.fasterxml.jackson.databind.RuntimeJsonMappingException: Can not construct instance of com.a9.ao.recency.aaxlogs.pojos.AAXImpressionLogView: no int/Int-argument constructor/factory method to deserialize from Number value (29)

Мой класс пожо

      package com.a9.ao.recency.aaxlogs.pojos;

import com.a9.ao.recency.constants.ViewabilityFeatureConstants;
import com.a9.ao.recency.misc.utility.AAXLogUtils;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class MyClass {

    @JsonProperty("sourceId")
    private String sourceId;

    @JsonProperty("bidId")
    private String bidId;

    @JsonProperty("bidderCategory")
    private String bidderCategory;

    @JsonProperty("userAgentInfo")
    private JsonNode userAgentInfoNode;

    @JsonProperty("sourceInfo")
    private JsonNode sourceInfoNode;

    @JsonProperty("responseMediaType")
    private String responseMediaType;

    @JsonProperty("impressionTime")
    private String impressionTime;

    @JsonProperty("zone")
    private String zone;
}

Логика, где я получаю эту ошибку:

      final MappingIterator<Object> iterator = objReader.readValues(s3Stream); //s3stream is of InputStream type, and is a stream of s3 object

        int lineCount = 0;
        while (iterator.hasNextValue()) {
            final MyClass logView = (MyClass) iterator.next();//This is the line throwing exception
            //Hook for processing a log-view
            ++lineCount;
        }

Я попытался преобразовать входной поток в s3 в строку, и, используя тот же код, он работает именно так. Добавление примера для справки, не уверен, что не так, может кто-нибудь помочь.

      String str1 = IOUtils.toString(s3Stream, StandardCharsets.UTF_8);
InputStream stream = new ByteArrayInputStream(str1.getBytes(StandardCharsets.UTF_8));
            ObjectReader objectReader = objectMapper.readerFor(MyClass.class);
            final MappingIterator<Object> iterator = objectReader.readValues(stream);
            while(iterator.hasNextValue()){
                MyClass p =(MyClass) iterator.next();//Works fine
            }

0 ответов

Другие вопросы по тегам