summaryrefslogtreecommitdiff
path: root/src/main/scala/spray/json/ProductFormats.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/spray/json/ProductFormats.scala')
-rw-r--r--src/main/scala/spray/json/ProductFormats.scala8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main/scala/spray/json/ProductFormats.scala b/src/main/scala/spray/json/ProductFormats.scala
index fecc7de..1f5f7cf 100644
--- a/src/main/scala/spray/json/ProductFormats.scala
+++ b/src/main/scala/spray/json/ProductFormats.scala
@@ -25,6 +25,14 @@ import java.lang.reflect.Modifier
trait ProductFormats {
this: StandardFormats =>
+ def jsonFormat0[T <: Product :ClassManifest](construct: () => T): RootJsonFormat[T] = {
+ jsonFormat(construct)
+ }
+ def jsonFormat[T <: Product](construct: () => T): RootJsonFormat[T] = new RootJsonFormat[T]{
+ def write(p: T) = JsObject()
+ def read(value: JsValue) = construct()
+ }
+
def jsonFormat1[A :JF, T <: Product :ClassManifest](construct: A => T): RootJsonFormat[T] = {
val Array(a) = extractFieldNames(classManifest[T])
jsonFormat(construct, a)