Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用@JsonRawValue注释序列化Json导致异常_Java_Json_Kotlin_Serialization_Escaping - Fatal编程技术网

Java 使用@JsonRawValue注释序列化Json导致异常

Java 使用@JsonRawValue注释序列化Json导致异常,java,json,kotlin,serialization,escaping,Java,Json,Kotlin,Serialization,Escaping,我有以下数据结构(Kotlin),它是RESTAPI post请求的响应实体(使用spring引导)。变量“innhold”包含动态/非结构化数据(格式正确),因此我希望保持原样,因此使用@JsonRawValue注释 在没有@JsonRawValue注释的情况下运行时,它工作得非常好,但会显示转义字符。使用@JsonRawValue注释运行时(为了去掉转义字符),我遇到以下异常: org.springframework.web.client.RestClientException:运行时出错

我有以下数据结构(Kotlin),它是RESTAPI post请求的响应实体(使用spring引导)。变量“innhold”包含动态/非结构化数据(格式正确),因此我希望保持原样,因此使用@JsonRawValue注释

在没有@JsonRawValue注释的情况下运行时,它工作得非常好,但会显示转义字符。使用@JsonRawValue注释运行时(为了去掉转义字符),我遇到以下异常:

org.springframework.web.client.RestClientException:运行时出错 正在提取类型[class]的响应 no.nav.bidrag.beregn.forskudd.rest.dto.http.beregnetforskudddresultat] 和内容类型[application/json];嵌套异常是 org.springframework.http.converter.httpMessageNodeTableException: JSON分析错误:无法反序列化
java.lang.String
启动外\u对象令牌;嵌套异常是 com.fasterxml.jackson.databind.exc.MismatchedInputException:无法 反序列化
java.lang.String
out-of-START\u对象标记的实例 在[源:(PushbackInputStream);行:1,列:403](通过 参考链: no.nav.bidrag.beregn.forskudd.rest.dto.http.beregnetforskudddresultat[“grunnlagListe”]->java.util.ArrayList[0]->no.nav.bidrag.beregn.forskudd.rest.dto.http.resultagrunnlag[“innhold”])

数据类BeregnetForskudResultat(
var beregnetforskudperiodeliste:List=emptyList(),
var grunnlagListe:List=emptyList()
) {
构造函数(BeregnetForskuAddressUltat:BeregnetForskuAddressUltatCore,grunnlagListe:List):此(
beregnetforskudperiodeliste=beregnetforskudddresultat.beregnetforskudperiodeliste.map{ResultatPeriode(it)},
grunnlagListe=grunnlagListe
)
}
数据类结果周期(
变量periode:periode=periode(),
var result-tat:resultaberging=resultaberging(),
var grunnlagrefereanseliste:List=emptyList()
) {
构造函数(ResultaPeriode:ResultaPeriodCore):这个(
periode=periode(结果periode.periode),
resultat=resultaberigning(resultaperide.resultat),
grunnlagrefereanseliste=resultatPeriode.grunnlagrefereanseliste
)
}
数据类结果设计(
变量belop:BigDecimal=BigDecimal.ZERO,
var kode:String=“”,
var regel:String=“”
) {
构造函数(ResultAbreigning:ResultAbreigningCore):这个(
belop=resultabreigning.belop,
kode=resultaberging.kode,
regel=resultabreigning.regel
)
}
数据类resultagrunnlag(
val refereanse:String=“”,
val type:String=“”,
@JsonRawValue val innhold:String=“”
)
data class BeregnetForskuddResultat(
  var beregnetForskuddPeriodeListe: List<ResultatPeriode> = emptyList(),
  var grunnlagListe: List<ResultatGrunnlag> = emptyList()
) {

  constructor(beregnetForskuddResultat: BeregnetForskuddResultatCore, grunnlagListe: List<ResultatGrunnlag>) : this(
    beregnetForskuddPeriodeListe = beregnetForskuddResultat.beregnetForskuddPeriodeListe.map { ResultatPeriode(it) },
    grunnlagListe = grunnlagListe
  )
}

data class ResultatPeriode(
  var periode: Periode = Periode(),
  var resultat: ResultatBeregning = ResultatBeregning(),
  var grunnlagReferanseListe: List<String> = emptyList()
) {

  constructor(resultatPeriode: ResultatPeriodeCore) : this(
    periode = Periode(resultatPeriode.periode),
    resultat = ResultatBeregning(resultatPeriode.resultat),
    grunnlagReferanseListe = resultatPeriode.grunnlagReferanseListe
  )
}

data class ResultatBeregning(
  var belop: BigDecimal = BigDecimal.ZERO,
  var kode: String = "",
  var regel: String = ""
) {

  constructor(resultatBeregning: ResultatBeregningCore) : this(
    belop = resultatBeregning.belop,
    kode = resultatBeregning.kode,
    regel = resultatBeregning.regel
  )
}

data class ResultatGrunnlag(
  val referanse: String = "",
  val type: String = "",
  @JsonRawValue val innhold: String = ""
)