question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No implicit 'com.github.plokhotnyuk.jsoniter_scala.core.JsonValueCodec[_]' defined for 'Any'

See original GitHub issue

当case class里面有Any类型时,或者Map的值是any类型时,编译会报错。

case class GenericMetric(timestamp: Long, metric: String, value: Any, tags: Map[String, String])

implicit val codec: JsonValueCodec[GenericMetric] = JsonCodecMaker.make[GenericMetric](CodecMakerConfig())

或者

case class GenericMetric(timestamp: Long, metric: String, value: Double, tags: Map[String, Any])
implicit val codec: JsonValueCodec[GenericMetric] = JsonCodecMaker.make[GenericMetric](CodecMakerConfig())

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
plokhotnyukcommented, Mar 26, 2019

If you have only String and Int types for map values than instead of Any you can use Either[String, Int] with a custom codec like here.

0reactions
DongchaoXucommented, May 11, 2022

@plokhotnyuk Following this question, I am trying Either[String, Int] with the custom codec here. While I got the CodecConfigurationException: Can’t find a codec for class scala.util.Left. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

plokhotnyuk/jsoniter-scala - Gitter
if you can define your codecs in the companion classes then they will be in different scopes ... object Leaf1 { implicit val...
Read more >
What is Scala 3 equivalent to this Scala 2 code that uses ...
As an option you can switch to jsoniter-scala. It supports enums for Scala 2 and ... import com.github.plokhotnyuk.jsoniter_scala.core.
Read more >
com.github.plokhotnyuk.jsoniter_scala.macros ...
inferImplicitValue(getType(tq"com.github.plokhotnyuk.jsoniter_scala.core. ... fail(s"No implicit '${typeOf[JsonValueCodec[_]]}' defined for '$tpe'.
Read more >
jsoniter-scala - Bountysource
_ import com.github.plokhotnyuk.jsoniter_scala.core. ... simdjson is probably the fastest json library on earth, jsoniter-scala might be the second fastest!
Read more >
The fastest and safest JSON parser and serializer for Scala
Use the %%% operator instead of %% for Scala.js and Scala Native "com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-core" % "2.19.0" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found