summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/json/json-test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/modules/json/json-test.cpp')
-rw-r--r--sca-cpp/trunk/modules/json/json-test.cpp114
1 files changed, 61 insertions, 53 deletions
diff --git a/sca-cpp/trunk/modules/json/json-test.cpp b/sca-cpp/trunk/modules/json/json-test.cpp
index eed41c4e59..157e012b5a 100644
--- a/sca-cpp/trunk/modules/json/json-test.cpp
+++ b/sca-cpp/trunk/modules/json/json-test.cpp
@@ -37,31 +37,32 @@ ostream* jsonWriter(const string& s, ostream* os) {
}
const string jscustomer("{\n"
- " \"customer\":{\n"
- " \"@name\":\"jdoe\",\n"
- " \"address\":{\n"
- " \"@city\":\"san francisco\",\n"
- " \"@state\":\"ca\"\n"
+ " \"customer\": {\n"
+ " \"@name\": \"jdoe\",\n"
+ " \"address\": {\n"
+ " \"@city\": \"san francisco\",\n"
+ " \"@state\": \"ca\"\n"
" },\n"
- " \"account\":{\n"
- " \"id\":\"1234\",\n"
- " \"@balance\":1000\n"
+ " \"account\": {\n"
+ " \"id\": \"1234\",\n"
+ " \"@balance\": 1000\n"
" }\n"
" }\n"
"}");
const string jsphones("{\n"
- " \"phones\":[\"408-1234\",\n"
+ " \"phones\": [\n"
+ " \"408-1234\",\n"
" \"650-1234\"\n"
" ],\n"
- " \"lastName\":\"test\\u0009tab\",\n"
- " \"@firstName\":\"test1\"\n"
+ " \"lastName\": \"test\\u0009tab\",\n"
+ " \"@firstName\": \"test1\"\n"
"}");
const string jsecho("{\n"
- " \"ns1:echoString\":{\n"
- " \"@xmlns:ns1\":\"http://ws.apache.org/axis2/services/echo\",\n"
- " \"text\":\"Hello World!\"\n"
+ " \"ns1:echoString\": {\n"
+ " \"@xmlns:ns1\": \"http://ws.apache.org/axis2/services/echo\",\n"
+ " \"text\": \"Hello World!\"\n"
" }\n"
"}");
@@ -110,81 +111,88 @@ bool testJSON() {
}
const string jsitem("{\n"
- " \"id\":3,\n"
- " \"result\":[{\n"
- " \"price\":\"$2.99\",\n"
- " \"name\":\"Apple\"\n"
+ " \"id\": 3,\n"
+ " \"result\": [\n"
+ " {\n"
+ " \"price\": \"$2.99\",\n"
+ " \"name\": \"Apple\"\n"
" },\n"
" {\n"
- " \"price\":\"$3.55\",\n"
- " \"name\":\"Orange\"\n"
+ " \"price\": \"$3.55\",\n"
+ " \"name\": \"Orange\"\n"
" },\n"
" {\n"
- " \"price\":\"$1.55\",\n"
- " \"name\":\"Pear\"\n"
+ " \"price\": \"$1.55\",\n"
+ " \"name\": \"Pear\"\n"
" }\n"
" ]\n"
"}");
const string jsresult("{\n"
- " \"id\":1,\n"
- " \"result\":[\"Service.get\",\n"
+ " \"id\": 1,\n"
+ " \"result\": [\n"
+ " \"Service.get\",\n"
" \"Service.getTotal\"\n"
" ]\n"
"}");
const string jsfeed("{\n"
- " \"id\":1,\n"
- " \"result\":[\"Sample Feed\",\n"
+ " \"id\": 1,\n"
+ " \"result\": [\n"
+ " \"Sample Feed\",\n"
" \"123456789\",\n"
- " [\"Item\",\n"
+ " [\n"
+ " \"Item\",\n"
" \"111\",\n"
" {\n"
- " \"name\":\"Apple\",\n"
- " \"currencyCode\":\"USD\",\n"
- " \"currencySymbol\":\"$\",\n"
- " \"price\":2.99\n"
+ " \"name\": \"Apple\",\n"
+ " \"currencyCode\": \"USD\",\n"
+ " \"currencySymbol\": \"$\",\n"
+ " \"price\": 2.99\n"
" }\n"
" ],\n"
- " [\"Item\",\n"
+ " [\n"
+ " \"Item\",\n"
" \"222\",\n"
" {\n"
- " \"name\":\"Orange\",\n"
- " \"currencyCode\":\"USD\",\n"
- " \"currencySymbol\":\"$\",\n"
- " \"price\":3.55\n"
+ " \"name\": \"Orange\",\n"
+ " \"currencyCode\": \"USD\",\n"
+ " \"currencySymbol\": \"$\",\n"
+ " \"price\": 3.55\n"
" }\n"
" ],\n"
- " [\"Item\",\n"
+ " [\n"
+ " \"Item\",\n"
" \"333\",\n"
" {\n"
- " \"name\":\"Pear\",\n"
- " \"currencyCode\":\"USD\",\n"
- " \"currencySymbol\":\"$\",\n"
- " \"price\":1.55\n"
+ " \"name\": \"Pear\",\n"
+ " \"currencyCode\": \"USD\",\n"
+ " \"currencySymbol\": \"$\",\n"
+ " \"price\": 1.55\n"
" }\n"
" ]\n"
" ]\n"
"}");
const string jsechoreq("{\n"
- " \"id\":1,\n"
- " \"method\":\"echo\",\n"
- " \"params\":[{\n"
- " \"ns1:echoString\":{\n"
- " \"@xmlns:ns1\":\"http://ws.apache.org/axis2/services/echo\",\n"
- " \"text\":\"Hello World!\"\n"
+ " \"id\": 1,\n"
+ " \"method\": \"echo\",\n"
+ " \"params\": [\n"
+ " {\n"
+ " \"ns1:echoString\": {\n"
+ " \"@xmlns:ns1\": \"http://ws.apache.org/axis2/services/echo\",\n"
+ " \"text\": \"Hello World!\"\n"
" }\n"
" }\n"
" ]\n"
"}");
const string jsechores("{\n"
- " \"id\":1,\n"
- " \"result\":{\n"
- " \"ns1:echoString\":{\n"
- " \"@xmlns:ns1\":\"http://ws.apache.org/axis2/c/samples\",\n"
- " \"text\":\"Hello World!\"\n"
+ " \"id\": 1,\n"
+ " \"result\": {\n"
+ " \"ns1:echoString\": {\n"
+ " \"@xmlns:ns1\": \"http://ws.apache.org/axis2/c/samples\",\n"
+ " \"text\": \"Hello World!\"\n"
" }\n"
" }\n"
"}");
@@ -200,7 +208,7 @@ bool testJSONRPC() {
assert(assoc<value>("params", v) == mklist<value>("params", list<value>()));
}
{
- const string i2 = "{\"id\":3,\"result\":{\"0\":{\"price\":\"$2.99\",\"name\":\"Apple\"},\"1\":{\"price\":\"$3.55\",\"name\":\"Orange\"},\"2\":{\"price\":\"$1.55\",\"name\":\"Pear\"}}}";
+ const string i2 = "{\"id\": 3,\"result\": {\"0\": {\"price\": \"$2.99\",\"name\": \"Apple\"},\"1\": {\"price\": \"$3.55\",\"name\": \"Orange\"},\"2\": {\"price\": \"$1.55\",\"name\": \"Pear\"}}}";
const list<value> e = content(readJSON(mklist(jsitem), cx));
const list<value> e2 = content(readJSON(mklist(i2), cx));
assert(e == e2);