Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix InputValue.ObjectValue jsoniter encoder #2018

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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