Skip to content

Commit

Permalink
Fix InputValue.ListValue jsoniter encoder (#2018)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyri-petrou authored Nov 22, 2023
1 parent 8db6b8c commit 05858ab
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions core/src/main/scala/caliban/interop/jsoniter/jsoniter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import caliban._
import caliban.parsing.adt.LocationInfo
import com.github.plokhotnyuk.jsoniter_scala.core._

import scala.annotation.switch
import scala.collection.immutable.TreeMap

/**
Expand Down Expand Up @@ -52,18 +51,17 @@ private[caliban] object ValueJsoniter {
val depthM1 = depth - 1
if (depthM1 < 0) out.encodeError("depth limit exceeded")
out.writeArrayStart()
l.foreach(v => encodeInputValue(v, out, depthM1))
l.foreach(encodeInputValue(_, out, depthM1))
out.writeArrayEnd()
case InputValue.ObjectValue(o) =>
val depthM1 = depth - 1
val depthM1 = depth - 1
if (depthM1 < 0) out.encodeError("depth limit exceeded")
out.writeObjectStart()
var remaining = o
while (!remaining.isEmpty) {
val (k, v) = remaining.head
val iterator = o.iterator
while (iterator.hasNext) {
val (k, v) = iterator.next()
out.writeKey(k)
encodeInputValue(v, out, depthM1)
remaining = remaining.tail
}
out.writeObjectEnd()
case InputValue.VariableValue(v) => out.writeVal(v)
Expand All @@ -84,7 +82,7 @@ private[caliban] object ValueJsoniter {
val depthM1 = depth - 1
if (depthM1 < 0) out.encodeError("depth limit exceeded")
out.writeArrayStart()
l.foreach(v => encodeResponseValue(v, out, depthM1))
l.foreach(encodeResponseValue(_, out, depthM1))
out.writeArrayEnd()
case ResponseValue.ObjectValue(o) =>
val depthM1 = depth - 1
Expand Down

0 comments on commit 05858ab

Please sign in to comment.