diff options
author | Mathias <mathias@spray.cc> | 2011-05-09 09:57:13 +0200 |
---|---|---|
committer | Mathias <mathias@spray.cc> | 2011-05-09 09:57:13 +0200 |
commit | 7146a4af52a888f0cdf1a806cf640ef243e82a6c (patch) | |
tree | c0f41d242f2053674bfe2f6f0b005b8a2b2f0897 /src/main/scala/cc/spray | |
parent | b9b9ae1bc56362695217bb2a8850586700c0315a (diff) | |
download | spray-json-7146a4af52a888f0cdf1a806cf640ef243e82a6c.tar.gz spray-json-7146a4af52a888f0cdf1a806cf640ef243e82a6c.tar.bz2 spray-json-7146a4af52a888f0cdf1a806cf640ef243e82a6c.zip |
Squash sub package 'formats'
Diffstat (limited to 'src/main/scala/cc/spray')
-rw-r--r-- | src/main/scala/cc/spray/json/BasicFormats.scala (renamed from src/main/scala/cc/spray/json/formats/BasicFormats.scala) | 1 | ||||
-rw-r--r-- | src/main/scala/cc/spray/json/CollectionFormats.scala (renamed from src/main/scala/cc/spray/json/formats/CollectionFormats.scala) | 1 | ||||
-rw-r--r-- | src/main/scala/cc/spray/json/DefaultJsonProtocol.scala (renamed from src/main/scala/cc/spray/json/formats/DefaultJsonFormats.scala) | 5 | ||||
-rw-r--r-- | src/main/scala/cc/spray/json/GenericFormats.scala (renamed from src/main/scala/cc/spray/json/formats/GenericFormats.scala) | 21 | ||||
-rw-r--r-- | src/main/scala/cc/spray/json/JsValue.scala | 1 | ||||
-rw-r--r-- | src/main/scala/cc/spray/json/JsonFormat.scala (renamed from src/main/scala/cc/spray/json/formats/JsonFormat.scala) | 1 | ||||
-rw-r--r-- | src/main/scala/cc/spray/json/PimpedAny.scala | 25 | ||||
-rw-r--r-- | src/main/scala/cc/spray/json/StandardFormats.scala (renamed from src/main/scala/cc/spray/json/formats/StandardFormats.scala) | 1 | ||||
-rw-r--r-- | src/main/scala/cc/spray/json/package.scala | 8 |
9 files changed, 18 insertions, 46 deletions
diff --git a/src/main/scala/cc/spray/json/formats/BasicFormats.scala b/src/main/scala/cc/spray/json/BasicFormats.scala index 4be7ef6..e16b4ca 100644 --- a/src/main/scala/cc/spray/json/formats/BasicFormats.scala +++ b/src/main/scala/cc/spray/json/BasicFormats.scala @@ -16,7 +16,6 @@ */ package cc.spray.json -package formats /** * Provides the JsonFormats for the most important Scala types. diff --git a/src/main/scala/cc/spray/json/formats/CollectionFormats.scala b/src/main/scala/cc/spray/json/CollectionFormats.scala index 02a9999..2bce527 100644 --- a/src/main/scala/cc/spray/json/formats/CollectionFormats.scala +++ b/src/main/scala/cc/spray/json/CollectionFormats.scala @@ -16,7 +16,6 @@ */ package cc.spray.json -package formats import reflect.Manifest diff --git a/src/main/scala/cc/spray/json/formats/DefaultJsonFormats.scala b/src/main/scala/cc/spray/json/DefaultJsonProtocol.scala index 15f2abb..a8201c2 100644 --- a/src/main/scala/cc/spray/json/formats/DefaultJsonFormats.scala +++ b/src/main/scala/cc/spray/json/DefaultJsonProtocol.scala @@ -16,11 +16,10 @@ */ package cc.spray.json -package formats /** * Provides all the predefined JsonFormats. */ -trait DefaultJsonFormats extends BasicFormats with StandardFormats with CollectionFormats with GenericFormats +trait DefaultJsonProtocol extends BasicFormats with StandardFormats with CollectionFormats with GenericFormats -object DefaultJsonFormats extends DefaultJsonFormats +object DefaultJsonProtocol extends DefaultJsonProtocol diff --git a/src/main/scala/cc/spray/json/formats/GenericFormats.scala b/src/main/scala/cc/spray/json/GenericFormats.scala index dbfb264..aa1da08 100644 --- a/src/main/scala/cc/spray/json/formats/GenericFormats.scala +++ b/src/main/scala/cc/spray/json/GenericFormats.scala @@ -16,7 +16,6 @@ */ package cc.spray.json -package formats /** * Provides the helpers for constructing custom JsonFormat implementations. @@ -34,7 +33,7 @@ trait GenericFormats { def read(value: JsValue) = delegate.read(value); } - def format[A :JF, B :JF, T <: Product](construct: (A, B) => T, a: String, b: String) = new JF[T]{ + def jsonFormat[A :JF, B :JF, T <: Product](construct: (A, B) => T, a: String, b: String) = new JF[T]{ def write(p: T) = JsObject( JsField(a, element[A](p, 0).toJson), JsField(b, element[B](p, 1).toJson) @@ -45,7 +44,7 @@ trait GenericFormats { ) } - def format[A :JF, B :JF, C :JF, T <: Product](construct: (A, B, C) => T, + def jsonFormat[A :JF, B :JF, C :JF, T <: Product](construct: (A, B, C) => T, a: String, b: String, c: String) = new JF[T]{ def write(p: T) = JsObject( JsField(a, element[A](p, 0).toJson), @@ -59,7 +58,7 @@ trait GenericFormats { ) } - def format[A :JF, B :JF, C :JF, D :JF, T <: Product](construct: (A, B, C, D) => T, + def jsonFormat[A :JF, B :JF, C :JF, D :JF, T <: Product](construct: (A, B, C, D) => T, a: String, b: String, c: String, d: String) = new JF[T]{ def write(p: T) = JsObject( JsField(a, element[A](p, 0).toJson), @@ -75,7 +74,7 @@ trait GenericFormats { ) } - def format[A :JF, B :JF, C :JF, D :JF, E :JF, T <: Product](construct: (A, B, C, D, E) => T, + def jsonFormat[A :JF, B :JF, C :JF, D :JF, E :JF, T <: Product](construct: (A, B, C, D, E) => T, a: String, b: String, c: String, d: String, e: String) = new JF[T]{ def write(p: T) = JsObject( JsField(a, element[A](p, 0).toJson), @@ -93,7 +92,7 @@ trait GenericFormats { ) } - def format[A :JF, B :JF, C :JF, D :JF, E :JF, F :JF, T <: Product](construct: (A, B, C, D, E, F) => T, + def jsonFormat[A :JF, B :JF, C :JF, D :JF, E :JF, F :JF, T <: Product](construct: (A, B, C, D, E, F) => T, a: String, b: String, c: String, d: String, e: String, f: String) = new JF[T]{ def write(p: T) = JsObject( JsField(a, element[A](p, 0).toJson), @@ -113,7 +112,7 @@ trait GenericFormats { ) } - def format[A :JF, B :JF, C :JF, D :JF, E :JF, F :JF, G :JF, T <: Product](construct: (A, B, C, D, E, F, G) => T, + def jsonFormat[A :JF, B :JF, C :JF, D :JF, E :JF, F :JF, G :JF, T <: Product](construct: (A, B, C, D, E, F, G) => T, a: String, b: String, c: String, d: String, e: String, f: String, g: String) = new JF[T]{ def write(p: T) = JsObject( JsField(a, element[A](p, 0).toJson), @@ -135,7 +134,7 @@ trait GenericFormats { ) } - def format[A :JF, B :JF, C :JF, D :JF, E :JF, F :JF, G :JF, H :JF, T <: Product] + def jsonFormat[A :JF, B :JF, C :JF, D :JF, E :JF, F :JF, G :JF, H :JF, T <: Product] (construct: (A, B, C, D, E, F, G, H) => T, a: String, b: String, c: String, d: String, e: String, f: String, g: String, h: String) = new JF[T]{ def write(p: T) = JsObject( @@ -160,7 +159,7 @@ trait GenericFormats { ) } - def format[A :JF, B :JF, C :JF, D :JF, E :JF, F :JF, G :JF, H :JF, I :JF, T <: Product] + def jsonFormat[A :JF, B :JF, C :JF, D :JF, E :JF, F :JF, G :JF, H :JF, I :JF, T <: Product] (construct: (A, B, C, D, E, F, G, H, I) => T, a: String, b: String, c: String, d: String, e: String, f: String, g: String, h: String, i: String) = new JF[T]{ def write(p: T) = JsObject( @@ -187,7 +186,7 @@ trait GenericFormats { ) } - def format[A :JF, B :JF, C :JF, D :JF, E :JF, F :JF, G :JF, H :JF, I :JF, J :JF, T <: Product] + def jsonFormat[A :JF, B :JF, C :JF, D :JF, E :JF, F :JF, G :JF, H :JF, I :JF, J :JF, T <: Product] (construct: (A, B, C, D, E, F, G, H, I, J) => T, a: String, b: String, c: String, d: String, e: String, f: String, g: String, h: String, i: String, j: String) = new JF[T]{ def write(p: T) = JsObject( @@ -216,7 +215,7 @@ trait GenericFormats { ) } - def format[A :JF, B :JF, C :JF, D :JF, E :JF, F :JF, G :JF, H :JF, I :JF, J :JF, K :JF, T <: Product] + def jsonFormat[A :JF, B :JF, C :JF, D :JF, E :JF, F :JF, G :JF, H :JF, I :JF, J :JF, K :JF, T <: Product] (construct: (A, B, C, D, E, F, G, H, I, J, K) => T, a: String, b: String, c: String, d: String, e: String, f: String, g: String, h: String, i: String, j: String, k: String) = new JF[T]{ def write(p: T) = JsObject( diff --git a/src/main/scala/cc/spray/json/JsValue.scala b/src/main/scala/cc/spray/json/JsValue.scala index f98103c..18e302e 100644 --- a/src/main/scala/cc/spray/json/JsValue.scala +++ b/src/main/scala/cc/spray/json/JsValue.scala @@ -18,7 +18,6 @@ package cc.spray.json -import formats._ import collection.mutable.ListBuffer /** diff --git a/src/main/scala/cc/spray/json/formats/JsonFormat.scala b/src/main/scala/cc/spray/json/JsonFormat.scala index 0951ef8..94a2576 100644 --- a/src/main/scala/cc/spray/json/formats/JsonFormat.scala +++ b/src/main/scala/cc/spray/json/JsonFormat.scala @@ -16,7 +16,6 @@ */ package cc.spray.json -package formats /** * Provides the JSON deserialization for type T. diff --git a/src/main/scala/cc/spray/json/PimpedAny.scala b/src/main/scala/cc/spray/json/PimpedAny.scala deleted file mode 100644 index 4c10771..0000000 --- a/src/main/scala/cc/spray/json/PimpedAny.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2009-2011 Mathias Doenitz - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package cc.spray.json - -import formats.JsonWriter - -private[json] class PimpedAny[T](any: T, writer: JsonWriter[T]) { - - def toJson: JsValue = writer.write(any) - -}
\ No newline at end of file diff --git a/src/main/scala/cc/spray/json/formats/StandardFormats.scala b/src/main/scala/cc/spray/json/StandardFormats.scala index 78bbe53..2a07d6c 100644 --- a/src/main/scala/cc/spray/json/formats/StandardFormats.scala +++ b/src/main/scala/cc/spray/json/StandardFormats.scala @@ -16,7 +16,6 @@ */ package cc.spray.json -package formats /** * Provides the JsonFormats for the non-collection standard types. diff --git a/src/main/scala/cc/spray/json/package.scala b/src/main/scala/cc/spray/json/package.scala index 362fb7b..a5daedb 100644 --- a/src/main/scala/cc/spray/json/package.scala +++ b/src/main/scala/cc/spray/json/package.scala @@ -16,8 +16,6 @@ package cc.spray -import json.formats.{JsonReader, JsonWriter} - package object json { def jsonReader[T](implicit reader: JsonReader[T]) = reader @@ -25,4 +23,10 @@ package object json { implicit def pimpAny[T :JsonWriter](any: T): PimpedAny[T] = new PimpedAny(any, jsonWriter) +} + +package json { + private[json] class PimpedAny[T](any: T, writer: JsonWriter[T]) { + def toJson: JsValue = writer.write(any) + } }
\ No newline at end of file |