score:0
It seems that this will work:
implicit def emptyArrToEmptyDict[T: Reader]: Reader[Map[String, T]] = {
reader[ujson.Value].map[Map[String, T]] {
case ujson.Arr(array) if array.length == 0 => Map()
case other => other.obj.map { case (k, v) => (k -> v.transform(implicitly[Reader[T]])) }.toMap
}
}
uPickle should pick it up automatically if you put it in some object and you import the emptyArrToEmptyDict
name to the global namespace.
Source: stackoverflow.com
Related Query
- Is it possible to parse an empty sequence to an Obj?
- How do I use Scala to parse CSV data with empty columns?
- Scala: Matching empty sequence against Nil
- Can the Scala parser framework parse a sequence supplied in "push" mode?
- Is there a way to determine whether it is possible to call a dialog.dismiss() without empty try-catch block?
- Calling from/until/range twice on a mutable TreeSet results in empty sequence
- Possible to make a producer/consumer obj in Scala using actors 'threadless' (no receive...)?
- Play json parse missing field as empty array
- Creating empty scala mutable sequence and adding to it
- Is it possible to parse JSON array into a tuple with json4s?
- How to parse empty [] using spray.json
- Is it possible to obtain the parse tree to a method in scala?
- Is it possible to use Scala's parser combinator to parse a JSON text file line by line?
- Is it possible to parse Json in build.sbt?
- Parse Json Sequence without keys in playframework
- Is it possible to flatten this particular sequence in scala?
- Json Parse obj without case class ref
- Is it possible to parse Scala with JDT
- unable to detect empty for Sequence using map function in scala
- How to parse JSON empty string as `None` using Play Json?
- How do I remove empty dataframes from a sequence of dataframes in Scala
- Sequence map throws an error: NoSuchElementException: next on empty iterator
- How to parse a string and transform it into a sequence in Spark Scala
- Sequence of futures in Scala are empty
- Is it possible to remove a row from an RDD that has an empty string in the row?
- Possible ways to check if a value exists in a sequence scala
- Best way to parse command-line parameters?
- How to split a sequence into two pieces by predicate?
- Why does "split" on an empty string return a non-empty array?
- How to parse JSON in Scala using standard Scala classes?
More Query from same tag
- Option is both a functor and a monad?
- Using sbt-dynver with git submodules
- Why the expr parser only can parse the first item of it?
- How to compute a list of validators and return a Seq[String]
- Scala: Higher order function to return the union of sets
- working with cookies in dispatch-classic
- How Ordering works in Scala
- Gatling how to send json body to avoid unmarshal error
- Split String into alternating words (Scala)
- In Java or Scala, how to define conditional control flow based on whether type bound is satisfied?
- running spark job on local cluster runs infinitely
- Scala: is it possible to override default case class constructor?
- Slick 3.0.0 - How to sortBy on a query with joinLeft
- split String by two separator (, and "") in Scala
- Creating a new folder and copying the current files to the new folder with SBT
- Scala class inheriting from a Java generic class
- Play framework 2.2.1 app terminates with a strange Killed message
- How to handle backward compatibility (field name change) in Jackson?
- scala calculate number of occurences of an element
- Assertion Failure when trying to create OneToMany Relation using Squeryl
- Transform Array[Seq[(Int, String)]] to Seq[(Int, String)] in SCALA
- How to execute user-defined function that accepts and returns another?
- Batch insert with table that has many columns using Anorm
- SBT fails to resolve dependency for jersey-container-grizzly2-http 2.5.1
- Is there any way to load an application context using a custom BeanWrapper implementation
- Scala: Return type of copy method when implicit evidence parameter has a representation type
- How to write unit test for my tagless algebra?
- working with java iterators in Scala
- How to transform DataFrame before joining operation?
- Task not serializable: java.io.NotSerializableException - JsonSchema