summaryrefslogtreecommitdiff
path: root/src/main/scala/spray
diff options
context:
space:
mode:
authorConnor Doyle <connor_doyle@gensler.com>2012-11-28 13:21:42 -0600
committerConnor Doyle <connor_doyle@gensler.com>2012-11-28 13:21:42 -0600
commitac1c3f8eee6cdd5db2f4329a2fc39ab3c115f3a1 (patch)
treec1f22f372a010115441ee26b621a5b191994fe98 /src/main/scala/spray
parent303713ea4ce2784e89c463a2716f36768f0728bf (diff)
downloadspray-json-ac1c3f8eee6cdd5db2f4329a2fc39ab3c115f3a1.tar.gz
spray-json-ac1c3f8eee6cdd5db2f4329a2fc39ab3c115f3a1.tar.bz2
spray-json-ac1c3f8eee6cdd5db2f4329a2fc39ab3c115f3a1.zip
Added a jsonFormat0 method to ProductFormats.scala to support empty case classes, for completeness.
Diffstat (limited to 'src/main/scala/spray')
-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 5504fbd..b920d0a 100644
--- a/src/main/scala/spray/json/ProductFormats.scala
+++ b/src/main/scala/spray/json/ProductFormats.scala
@@ -23,6 +23,14 @@ package spray.json
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)