diff options
author | Connor Doyle <connor_doyle@gensler.com> | 2012-11-28 13:21:42 -0600 |
---|---|---|
committer | Connor Doyle <connor_doyle@gensler.com> | 2012-11-28 13:21:42 -0600 |
commit | ac1c3f8eee6cdd5db2f4329a2fc39ab3c115f3a1 (patch) | |
tree | c1f22f372a010115441ee26b621a5b191994fe98 | |
parent | 303713ea4ce2784e89c463a2716f36768f0728bf (diff) | |
download | spray-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.
-rw-r--r-- | src/main/scala/spray/json/ProductFormats.scala | 8 |
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) |