Sha256: 9c79965cd22b352c911bda4212c272c451fdbdb8ca5ca76fd4a5f37a8127bff8

Contents?: true

Size: 779 Bytes

Versions: 4

Compression:

Stored size: 779 Bytes

Contents

package org.embulk.parser.firebase_avro.json.event_dim

import org.embulk.parser.firebase_avro.define.root.event_dim.Params

import scala.collection.mutable
import io.circe._
import io.circe.syntax._
import org.embulk.parser.firebase_avro.json.CustomEncoder.mapEncoder

object EventParmsJsonSerializer {
  def apply(params: List[Params]): Option[Json] = {
    val map = mutable.Map[String, Any]()
    params.foreach { p =>
      val value: Option[Any] = p.value.flatMap { v =>
        v.float_value
          .orElse(v.double_value)
          .orElse(v.int_value)
          .orElse(v.string_value)
      }
      for {
        key   <- p.key
        value <- value
      } yield map.put(key, value)
    }
    if (map.nonEmpty) {
      Some(map.toMap.asJson)
    } else None
  }
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
embulk-parser-firebase_avro-0.1.3 src/main/scala/org/embulk/parser/firebase_avro/json/event_dim/EventParmsJsonSerializer.scala
embulk-parser-firebase_avro-0.1.2 src/main/scala/org/embulk/parser/firebase_avro/json/event_dim/EventParmsJsonSerializer.scala
embulk-parser-firebase_avro-0.1.1 src/main/scala/org/embulk/parser/firebase_avro/json/event_dim/EventParmsJsonSerializer.scala
embulk-parser-firebase_avro-0.1.0 src/main/scala/org/embulk/parser/firebase_avro/json/event_dim/EventParmsJsonSerializer.scala