serialization (pickling / marshalling) in scala?

1.6k views Asked by At

Are there are any examples, tutorials or docs for serialization / pickling / marshalling objects in Scala? I know of existence of scala.util.Marshal and scala.reflect.internal.pickling, but what is a difference between them? how can I use it? Is that some experimetal feature or can I use it in production ... ?

2

There are 2 answers

3
paradigmatic On BEST ANSWER

You should use either java serialization (I recommend using the Externalizable approach for complex cases). You can find lots of tutorials by googling "java serialization tutorial".

If you want to stay in Scala, you should have a look to SBinary which uses composable type classes. The project seems old and unmaintained but works like a charm with Scala 2.9.2. There's a tutorial link in the README and I'm currently writing another one.

1
Nabegh On

Not sure about the requirements you have, but it's worth looking at Google's Protocol Buffers and Apache Thrift. Both provide efficient mechanism for serialization.

There is a Protocol Buffers scala compiler ScalaBuff