summaryrefslogtreecommitdiff
path: root/test/files/run/json.scala
diff options
context:
space:
mode:
authorAntonio Cunei <antonio.cunei@epfl.ch>2010-05-28 15:34:32 +0000
committerAntonio Cunei <antonio.cunei@epfl.ch>2010-05-28 15:34:32 +0000
commit0b006e7762a8c3ec2f5d02c8c7c34b09511e6a47 (patch)
treed506f42b6847b9ece5240d062bb9e4b97a450019 /test/files/run/json.scala
parent5da8a164cdd276e191ab6429e5a64e02529bbe45 (diff)
downloadscala-0b006e7762a8c3ec2f5d02c8c7c34b09511e6a47.tar.gz
scala-0b006e7762a8c3ec2f5d02c8c7c34b09511e6a47.tar.bz2
scala-0b006e7762a8c3ec2f5d02c8c7c34b09511e6a47.zip
Re-enabled a number of previously disabled tests;
according to my tests, they all currently work.
Diffstat (limited to 'test/files/run/json.scala')
-rw-r--r--test/files/run/json.scala158
1 files changed, 158 insertions, 0 deletions
diff --git a/test/files/run/json.scala b/test/files/run/json.scala
new file mode 100644
index 0000000000..ec0bad7ebe
--- /dev/null
+++ b/test/files/run/json.scala
@@ -0,0 +1,158 @@
+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\" } }")
+ printJSON("{\"name\": \"\\u0022\"}")
+ printJSON("{\"age\": 0}")
+ 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"
+ ]
+}"""
+ //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/"}
+ ]
+}"""
+ //println(sample2)
+ printJSON(sample2)
+ println
+
+ // from http://json.org/example.html
+ val sample3 = """
+{"web-app": {
+ "servlet": [
+ {
+ "servlet-name": "cofaxCDS",
+ "servlet-class": "org.cofax.cds.CDSServlet",
+ "init-param": {
+ "configGlossary:installationAt": "Philadelphia, PA",
+ "configGlossary:adminEmail": "ksm@pobox.com",
+ "configGlossary:poweredBy": "Cofax",
+ "configGlossary:poweredByIcon": "/images/cofax.gif",
+ "configGlossary:staticPath": "/content/static",
+ "templateProcessorClass": "org.cofax.WysiwygTemplate",
+ "templateLoaderClass": "org.cofax.FilesTemplateLoader",
+ "templatePath": "templates",
+ "templateOverridePath": "",
+ "defaultListTemplate": "listTemplate.htm",
+ "defaultFileTemplate": "articleTemplate.htm",
+ "useJSP": false,
+ "jspListTemplate": "listTemplate.jsp",
+ "jspFileTemplate": "articleTemplate.jsp",
+ "cachePackageTagsTrack": 200,
+ "cachePackageTagsStore": 200,
+ "cachePackageTagsRefresh": 60,
+ "cacheTemplatesTrack": 100,
+ "cacheTemplatesStore": 50,
+ "cacheTemplatesRefresh": 15,
+ "cachePagesTrack": 200,
+ "cachePagesStore": 100,
+ "cachePagesRefresh": 10,
+ "cachePagesDirtyRead": 10,
+ "searchEngineListTemplate": "forSearchEnginesList.htm",
+ "searchEngineFileTemplate": "forSearchEngines.htm",
+ "searchEngineRobotsDb": "WEB-INF/robots.db",
+ "useDataStore": true,
+ "dataStoreClass": "org.cofax.SqlDataStore",
+ "redirectionClass": "org.cofax.SqlRedirection",
+ "dataStoreName": "cofax",
+ "dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver",
+ "dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon",
+ "dataStoreUser": "sa",
+ "dataStorePassword": "dataStoreTestQuery",
+ "dataStoreTestQuery": "SET NOCOUNT ON;select test='test';",
+ "dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log",
+ "dataStoreInitConns": 10,
+ "dataStoreMaxConns": 100,
+ "dataStoreConnUsageLimit": 100,
+ "dataStoreLogLevel": "debug",
+ "maxUrlLength": 500}},
+ {
+ "servlet-name": "cofaxEmail",
+ "servlet-class": "org.cofax.cds.EmailServlet",
+ "init-param": {
+ "mailHost": "mail1",
+ "mailHostOverride": "mail2"}},
+ {
+ "servlet-name": "cofaxAdmin",
+ "servlet-class": "org.cofax.cds.AdminServlet"},
+
+ {
+ "servlet-name": "fileServlet",
+ "servlet-class": "org.cofax.cds.FileServlet"},
+ {
+ "servlet-name": "cofaxTools",
+ "servlet-class": "org.cofax.cms.CofaxToolsServlet",
+ "init-param": {
+ "templatePath": "toolstemplates/",
+ "log": 1,
+ "logLocation": "/usr/local/tomcat/logs/CofaxTools.log",
+ "logMaxSize": "",
+ "dataLog": 1,
+ "dataLogLocation": "/usr/local/tomcat/logs/dataLog.log",
+ "dataLogMaxSize": "",
+ "removePageCache": "/content/admin/remove?cache=pages&id=",
+ "removeTemplateCache": "/content/admin/remove?cache=templates&id=",
+ "fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder",
+ "lookInContext": 1,
+ "adminGroupID": 4,
+ "betaServer": true}}],
+ "servlet-mapping": {
+ "cofaxCDS": "/",
+ "cofaxEmail": "/cofaxutil/aemail/*",
+ "cofaxAdmin": "/admin/*",
+ "fileServlet": "/static/*",
+ "cofaxTools": "/tools/*"},
+
+ "taglib": {
+ "taglib-uri": "cofax.tld",
+ "taglib-location": "/WEB-INF/tlds/cofax.tld"}
+ }
+}"""
+ //println(sample3)
+ printJSON(sample3)
+ println
+}