From a07d4945c1a301aeaf4b67411065b9adcfac1065 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 27 Feb 2012 03:26:51 +0000 Subject: Fix mapping between repeating XML elements, S-expression lists, and JSON array cells. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1294006 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/json/json-test.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'sca-cpp/trunk/modules/json/json-test.cpp') diff --git a/sca-cpp/trunk/modules/json/json-test.cpp b/sca-cpp/trunk/modules/json/json-test.cpp index 157e012b5a..ac68d7573d 100644 --- a/sca-cpp/trunk/modules/json/json-test.cpp +++ b/sca-cpp/trunk/modules/json/json-test.cpp @@ -66,6 +66,13 @@ const string jsecho("{\n" " }\n" "}"); +const string jsarray("{\n" + " \"fruit\": [\n" + " \"Apple\",\n" + " \"Orange\"\n" + " ]\n" + "}"); + bool testJSON() { const js::JSContext cx; @@ -107,6 +114,17 @@ bool testJSON() { const list r = elementsToValues(content(readJSON(il, cx))); assert(r == l); } + { + const list l = mklist((list() + "fruit" + string("Apple")), (list() + "fruit" + string("Orange"))); + ostringstream wos; + write(content(writeJSON(valuesToElements(l), cx)), wos); + assert(str(wos) == jsarray); + + istringstream is(str(wos)); + const list il = streamList(is); + const list r = elementsToValues(content(readJSON(il, cx))); + assert(r == l); + } return true; } -- cgit v1.2.3