How do I convert java.util.Map[String, Object] to scala.collection.immutable.Map[String, Any], so that all values in the original map (integers, booleans etc.) are converted to the right value to work well in Scala.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
In order to convert convert java.util.Map[String, Object] to scala.collection.immutable.Map[String,Object] , you need to simple import below statement in Scala Project and clean build.
Refer to below code:
As VonC says,
scala.collections.JavaConversion
supports mutable collections only, but you don't have to use a separate library. Mutable collections are derived fromTraversableOnce
which defines atoMap
method that returns an immutable Map:This will output
The
JavaConversions
package of Scala2.8 deals only with mutable collections.The scalaj-collection library might help here.