All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fasterxml.jackson.module.scala.ser.ScalaSerializers.scala Maven / Gradle / Ivy

Go to download

Add-on module for Jackson (http://jackson.codehaus.org) to support Scala (http://www.scala-lang.org/) data types.

There is a newer version: 1.9.3
Show newest version
package com.fasterxml.jackson.module.scala.ser

import org.codehaus.jackson.map._
import org.codehaus.jackson.`type`.JavaType

class ScalaSerializers extends Serializers.None {

  override def findSerializer(config: SerializationConfig,
					   javaType: JavaType,
					   beanDescription: BeanDescription,
					   beanProperty: BeanProperty): JsonSerializer[_] = {
		val clazz = javaType.getRawClass

		if (classOf[collection.Map[String, Any]].isAssignableFrom(clazz)) {
			new ScalaMapSerializer
		} else if (classOf[Iterable[Any]].isAssignableFrom(clazz)) {
			new ScalaIterableSerializer
		} else if (classOf[Option[Any]].isAssignableFrom(clazz)) {
			new ScalaOptionSerializer
		} else if (classOf[scala.Enumeration$Val].isAssignableFrom(clazz)) {
			new ScalaEnumerationSerializer
		} else {
			null
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy