summaryrefslogtreecommitdiff
path: root/tools/shared/src/main/scala/scala/scalajs/tools/json/AbstractJSONImpl.scala
diff options
context:
space:
mode:
authorHaoyi Li <haoyi@haoyi-mbp.corp.dropbox.com>2014-11-26 00:45:31 -0800
committerHaoyi Li <haoyi@haoyi-mbp.corp.dropbox.com>2014-11-26 00:45:31 -0800
commit2c4b142503bd2d871e6818b5cab8c38627d9e4a0 (patch)
tree6ba33d2980a1a7a1286100202a695c6631bd240e /tools/shared/src/main/scala/scala/scalajs/tools/json/AbstractJSONImpl.scala
downloadhands-on-scala-js-2c4b142503bd2d871e6818b5cab8c38627d9e4a0.tar.gz
hands-on-scala-js-2c4b142503bd2d871e6818b5cab8c38627d9e4a0.tar.bz2
hands-on-scala-js-2c4b142503bd2d871e6818b5cab8c38627d9e4a0.zip
Squashed 'examples/scala-js/' content from commit 47311ba
git-subtree-dir: examples/scala-js git-subtree-split: 47311ba693f949f204f27ea9475bb63425fbd4f3
Diffstat (limited to 'tools/shared/src/main/scala/scala/scalajs/tools/json/AbstractJSONImpl.scala')
-rw-r--r--tools/shared/src/main/scala/scala/scalajs/tools/json/AbstractJSONImpl.scala32
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/shared/src/main/scala/scala/scalajs/tools/json/AbstractJSONImpl.scala b/tools/shared/src/main/scala/scala/scalajs/tools/json/AbstractJSONImpl.scala
new file mode 100644
index 0000000..ad5d79e
--- /dev/null
+++ b/tools/shared/src/main/scala/scala/scalajs/tools/json/AbstractJSONImpl.scala
@@ -0,0 +1,32 @@
+package scala.scalajs.tools.json
+
+import java.io.{Reader, Writer}
+
+/** A JSON implementation. Has a representation type and methods to convert
+ * this type to/from primitives, lists and maps.
+ *
+ * Further, it can write/read a value of this type to a string.
+ */
+private[json] trait AbstractJSONImpl {
+
+ type Repr
+
+ def fromString(x: String): Repr
+ def fromNumber(x: Number): Repr
+ def fromBoolean(x: Boolean): Repr
+ def fromList(x: List[Repr]): Repr
+ def fromMap(x: Map[String, Repr]): Repr
+
+ def toString(x: Repr): String
+ def toNumber(x: Repr): Number
+ def toBoolean(x: Repr): Boolean
+ def toList(x: Repr): List[Repr]
+ def toMap(x: Repr): Map[String, Repr]
+
+ def serialize(x: Repr): String
+ def serialize(x: Repr, writer: Writer): Unit
+
+ def deserialize(str: String): Repr
+ def deserialize(reader: Reader): Repr
+
+}