Strange serialization of scala Map
See original GitHub issueIssue Description
Hey,
I tried to serialize this with upicke 0.2.2, scala 2.11.2, scala.js 0.5.3 :
case class RequestMessage(requestId: String, op: String, processor: String, args: Map[String, String])
write(RequestMessage(
"1d6d02bd-8e56-421d-9438-3bd6d0079ff1",
"eval",
"",
Map(
"gremlin" -> "g.v(x).out",
"bindings" -> "",
"language" -> "gremlin-groovy"
)
)
)
{"requestId":"1d6d02bd-8e56-421d-9438-3bd6d0079ff1","op":"eval","processor":"","args":[["gremlin","g.v(x).out"],["bindings",""],["language","gremlin-groovy"]]}
Do I need to implement unapply method for maps too in case classes? The map is serialized into some sort of list of arrays. Even if I serialize it directly it resolves to :
[["gremlin","g.v(x).out"],["bindings",""],["language","gremlin-groovy"]]
Issue Analytics
- State:
- Created 9 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Strange serialization of scala Map - com-lihaoyi/upickle - GitHub
Hey, I tried to serialize this with upicke 0.2.2, scala 2.11.2, scala.js 0.5.3 : case class RequestMessage(requestId: String, op: String, ...
Read more >Map can not be serializable in scala? - Stack Overflow
I am new to Scala. How come the "map" function is not serializable? How to make it serializable? For example, if my code...
Read more >Large Scala Maps Fail Serialization - Imran Rashid
Took me a little while to figure it out, but it turns out that large Maps in Scala are not serializable. The exception...
Read more >Scala Standard Library 2.13.4 - scala.collection.Map
Appends all elements of this map to a string builder using start, end, and separator strings.
Read more >Java and JSON – Jackson Serialization with ObjectMapper
Jackson serializes a Map as a JSON object whose keys are the keys' toString() representation (in this case it's the value itself). The...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For future reference, with scala.js the best possible way to handle Map[K, Any] is :
There is just one thing that is really hard to deal with and that’s the Map[K, Any] I hit dead end with… I wanted to use shapeless HMap, but it doesn’t give you keySet or let you iterate it. Would you please uplade the README and tell people what alternatives do they have ? That would be highly appreciated.
Messaging protocol of the server counterpart I’m communicating with is based on nested maps of various value data types : primitives, map and list of primitives