Skip to content

Commit be83662

Browse files
committed
More efficient serialization for OpenRTBWriting.circe and OpenRTBWriting.circeJsoniter benchmark
1 parent 49df44d commit be83662

File tree

1 file changed

+7
-2
lines changed
  • jsoniter-scala-benchmark/shared/src/main/scala/io/circe

1 file changed

+7
-2
lines changed

jsoniter-scala-benchmark/shared/src/main/scala/io/circe/Util.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ object Util {
4040

4141
def deepDropEmptyValues(json: Json): Json = json.foldWith(dropEmptyValueFolder)
4242

43-
def toJObject(fields: (String, Json)*): Json =
44-
Json.obj(fields.filterNot { case (_, v) => v.isNull || (v.isArray && v.asInstanceOf[JArray].value.isEmpty) }: _*)
43+
def toJObject(fields: (String, Json)*): Json = new JObject(JsonObject.fromLinkedHashMap {
44+
val map = new util.LinkedHashMap[String, Json]
45+
fields.foreach { case (k, v) =>
46+
if (!(v.isNull || v.isArray && v.asInstanceOf[JArray].value.isEmpty)) map.put(k, v)
47+
}
48+
map
49+
})
4550
}

0 commit comments

Comments
 (0)