summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2007-11-09 16:47:15 +0000
committermichelou <michelou@epfl.ch>2007-11-09 16:47:15 +0000
commita49aba6e8275d78d13003a959b240a4c8e4fca5b (patch)
treefc2b7e4e4e9c61b373df94e6176092bb5b4c3333 /test/files/run
parent35bd7a8255fb8c00b3dd08932a224e68a5ae2bfb (diff)
downloadscala-a49aba6e8275d78d13003a959b240a4c8e4fca5b.tar.gz
scala-a49aba6e8275d78d13003a959b240a4c8e4fca5b.tar.bz2
scala-a49aba6e8275d78d13003a959b240a4c8e4fca5b.zip
fixed ticket #136 (cnt'd)
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/json.check8
-rw-r--r--test/files/run/json.scala60
2 files changed, 68 insertions, 0 deletions
diff --git a/test/files/run/json.check b/test/files/run/json.check
new file mode 100644
index 0000000000..4c2dbf48a0
--- /dev/null
+++ b/test/files/run/json.check
@@ -0,0 +1,8 @@
+Some(List((name,value)))
+Some(List((name,va1ue)))
+Some(List((name,List((name1,va1ue1), (name2,va1ue2)))))
+
+Some(List((firstName,John), (lastName,Smith), (address,List((streetAddress,21 2nd Street), (city,New York), (state,NY), (postalCode,10021.0))), (phoneNumbers,List(212 732-1234, 646 123-4567))))
+
+Some(List((fullname,Sean Kelly), (org,SK Consulting), (emailaddrs,List(List((type,work), (value,kelly@seankelly.biz)), List((type,home), (pref,1.0), (value,kelly@seankelly.tv)))), (telephones,List(List((type,work), (pref,1.0), (value,+1 214 555 1212)), List((type,fax), (value,+1 214 555 1213)), List((type,mobile), (value,+1 214 555 1214)))), (addresses,List(List((type,work), (format,us), (value,1234 Main StnSpringfield, TX 78080-1216)), List((type,home), (format,us), (value,5678 Main StnSpringfield, TX 78080-1316)))), (urls,List(List((type,work), (value,http://seankelly.biz/)), List((type,home), (value,http://seankelly.tv/))))))
+
diff --git a/test/files/run/json.scala b/test/files/run/json.scala
new file mode 100644
index 0000000000..040dbd380e
--- /dev/null
+++ b/test/files/run/json.scala
@@ -0,0 +1,60 @@
+import scala.util.parsing.json._
+
+object Test extends Application {
+ def printJSON(s: String) {
+ println(JSON parse s)
+ }
+ printJSON("{\"name\": \"value\"}")
+ printJSON("{\"name\": \"va1ue\"}") // ticket #136
+ printJSON("{\"name\": { \"name1\": \"va1ue1\", \"name2\": \"va1ue2\" } }")
+ println
+
+ // from http://en.wikipedia.org/wiki/JSON
+ val sample1 = """
+{
+ "firstName": "John",
+ "lastName": "Smith",
+ "address": {
+ "streetAddress": "21 2nd Street",
+ "city": "New York",
+ "state": "NY",
+ "postalCode": 10021
+ },
+ "phoneNumbers": [
+ "212 732-1234",
+ "646 123-4567"
+ ]
+}""".mergeLines
+ //println(sample1)
+ printJSON(sample1)
+ println
+
+ // from http://www.developer.com/lang/jscript/article.php/3596836
+ val sample2 = """
+{
+ "fullname": "Sean Kelly",
+ "org": "SK Consulting",
+ "emailaddrs": [
+ {"type": "work", "value": "kelly@seankelly.biz"},
+ {"type": "home", "pref": 1, "value": "kelly@seankelly.tv"}
+ ],
+ "telephones": [
+ {"type": "work", "pref": 1, "value": "+1 214 555 1212"},
+ {"type": "fax", "value": "+1 214 555 1213"},
+ {"type": "mobile", "value": "+1 214 555 1214"}
+ ],
+ "addresses": [
+ {"type": "work", "format": "us",
+ "value": "1234 Main StnSpringfield, TX 78080-1216"},
+ {"type": "home", "format": "us",
+ "value": "5678 Main StnSpringfield, TX 78080-1316"}
+ ],
+ "urls": [
+ {"type": "work", "value": "http://seankelly.biz/"},
+ {"type": "home", "value": "http://seankelly.tv/"}
+ ]
+}""".mergeLines
+ //println(sample2)
+ printJSON(sample2)
+ println
+}