Skip to content

Commit

Permalink
2.12 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hamnis committed Jun 24, 2024
1 parent 34682b2 commit 29ce288
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion 27/src/main/scala/io/circe/jackson/JacksonCompat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ private[jackson] trait JacksonCompat {
protected def handleUnexpectedToken(context: DeserializationContext)(
klass: Class[_],
parser: JsonParser
): Unit =
): Unit = {
val _ = parser
throw context.mappingException(klass)
}

protected def objectNodeSetAll(node: ObjectNode, fields: java.util.Map[String, JsonNode]): JsonNode =
node.setAll(fields)
Expand Down
9 changes: 5 additions & 4 deletions shared/src/main/scala/io/circe/jackson/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import java.io._
import java.math.{ BigDecimal => JBigDecimal }
import java.nio.ByteBuffer
import scala.jdk.CollectionConverters._
import scala.collection.compat._

/**
* Support for Jackson-powered parsing and printing for circe.
Expand Down Expand Up @@ -87,8 +88,8 @@ package object jackson extends WithJacksonMapper with JacksonParser with Jackson
}
},
TextNode.valueOf(_),
array => JsonNodeFactory.instance.arrayNode.addAll(array.map(circeToJackson).asJava),
obj => objectNodeSetAll(JsonNodeFactory.instance.objectNode, obj.toMap.view.mapValues(circeToJackson).toMap.asJava)
array => JsonNodeFactory.instance.arrayNode.addAll(array.map(circeToJackson(_)).asJava),
obj => objectNodeSetAll(JsonNodeFactory.instance.objectNode, obj.toMap.view.mapValues(circeToJackson(_)).toMap.asJava)
)

/**
Expand All @@ -108,9 +109,9 @@ package object jackson extends WithJacksonMapper with JacksonParser with Jackson
Json.fromBigInt(node.bigIntegerValue)
}
case JsonNodeType.ARRAY =>
Json.fromValues(node.elements.asScala.map(jacksonToCirce).iterator.to(Iterable))
Json.fromValues(node.elements.asScala.map(jacksonToCirce(_)).to(Iterable))
case JsonNodeType.OBJECT =>
Json.fromFields(node.fields.asScala.map(m => (m.getKey, jacksonToCirce(m.getValue))).iterator.to(Iterable))
Json.fromFields(node.fields.asScala.map(m => (m.getKey, jacksonToCirce(m.getValue))).to(Iterable))
case _ => Json.Null
}

Expand Down

0 comments on commit 29ce288

Please sign in to comment.