From 4afc05d60e11878b7391eb9eda10a1cb5dff85c9 Mon Sep 17 00:00:00 2001 From: fmoga Date: Fri, 8 Jul 2011 04:02:26 +0000 Subject: Add test to demonstrate data conversion to/from JSON. Fix bug in the JSON array parser. Refactor salutes test. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1144149 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tuscany/sca/binding/websocket/runtime/JSONUtil.java | 6 +++++- .../binding/websocket/runtime/WebsocketServiceBindingProvider.java | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'sca-java-2.x/contrib/modules/binding-websocket/src/main') diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JSONUtil.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JSONUtil.java index 30a14dd8bb..e21a2402b1 100644 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JSONUtil.java +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/JSONUtil.java @@ -49,6 +49,7 @@ public class JSONUtil { List objects = new ArrayList(); int bracketNum = 0; int parNum = 0; + int quoteNum = 0; int startPos = 1; for (int i = 0; i < jsonArray.length(); i++) { switch (jsonArray.charAt(i)) { @@ -64,8 +65,11 @@ public class JSONUtil { case ']': parNum--; break; + case '\"': + quoteNum++; + break; case ',': - if ((bracketNum == 0) && (parNum == 1)) { + if ((bracketNum == 0) && (parNum == 1) && quoteNum % 2 == 0) { objects.add(jsonArray.substring(startPos, i)); startPos = i + 1; } diff --git a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java index efab714e5c..461b364b2f 100644 --- a/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java +++ b/sca-java-2.x/contrib/modules/binding-websocket/src/main/java/org/apache/tuscany/sca/binding/websocket/runtime/WebsocketServiceBindingProvider.java @@ -85,7 +85,6 @@ public class WebsocketServiceBindingProvider implements ServiceBindingProvider { } } websocketServers.clear(); - websocketServers = null; } } -- cgit v1.2.3