串行circe.json flink

发布于 2025-02-01 14:58:19 字数 734 浏览 3 评论 0原文

scala flink circe.json 格式中序列化JSON的问题。

我正在使用lib flink-adt type typeInformation 序列化器。

  implicit val jsonInfo: TypeInformation[Json] =
    deriveTypeInformation[Json]

这是错误消息:

magnolia: child class BiggerDecimalJsonNumber of class JsonNumber is neither final nor a case class

我还尝试了此。

  implicit val jsonInfo: TypeInformation[Json] =
    TypeInformation.of(classOf[Json])

它会编译,但是当我运行单位测试时崩溃。

Scala Flink has problems serializing json in circe.Json format.

I am using lib flink-adt to derive TypeInformation that contains the serializer.

  implicit val jsonInfo: TypeInformation[Json] =
    deriveTypeInformation[Json]

Here is the error message:

magnolia: child class BiggerDecimalJsonNumber of class JsonNumber is neither final nor a case class

I also tried this.

  implicit val jsonInfo: TypeInformation[Json] =
    TypeInformation.of(classOf[Json])

It compiles but crashes when I run unit test.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无人接听 2025-02-08 14:58:19

我通过添加new executionConfig()使用

该代码来使序列化器工作:

import io.circe._
import io.circe.syntax._
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.api.common.ExecutionConfig

    implicit val jsonTypeInformation: TypeInformation[Json] =
      TypeInformation.of(classOf[Json])
    val typeInformation = implicitly[TypeInformation[Json]]
    val json = """[{"level":"up","num":1.23,"valid":true}]""".asJson
    val ser = typeInformation.createSerializer(new ExecutionConfig())
    roundtrip(ser, json)

I got the serializer to work by adding new ExecutionConfig()

This code worked:

import io.circe._
import io.circe.syntax._
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.api.common.ExecutionConfig

    implicit val jsonTypeInformation: TypeInformation[Json] =
      TypeInformation.of(classOf[Json])
    val typeInformation = implicitly[TypeInformation[Json]]
    val json = """[{"level":"up","num":1.23,"valid":true}]""".asJson
    val ser = typeInformation.createSerializer(new ExecutionConfig())
    roundtrip(ser, json)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文