Blob Blame History Raw
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-core-client/pom.xml hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/pom.xml
--- hornetq-HornetQ_2_4_7_Final/hornetq-core-client/pom.xml	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/pom.xml	2016-07-18 10:12:50.610380604 +0200
@@ -44,6 +44,11 @@
          <artifactId>junit</artifactId>
          <scope>test</scope>
       </dependency>
+      <dependency>
+         <groupId>org.apache.geronimo.specs</groupId>
+         <artifactId>geronimo-json_1.0_spec</artifactId>
+         <version>1.0-alpha-1</version>
+      </dependency>
    </dependencies>
 
    <profiles>
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/api/core/JsonUtil.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/api/core/JsonUtil.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/api/core/JsonUtil.java	1970-01-01 01:00:00.000000000 +0100
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/api/core/JsonUtil.java	2016-07-18 10:10:45.084409402 +0200
@@ -0,0 +1,253 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.hornetq.api.core;
+
+import org.hornetq.core.client.HornetQClientMessageBundle;
+import org.hornetq.utils.Base64;
+
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonNumber;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public final class JsonUtil {
+   public static JsonArray toJSONArray(final Object[] array) throws Exception {
+      JsonArrayBuilder jsonArray = Json.createArrayBuilder();
+
+      for (Object parameter : array) {
+         if (parameter instanceof Map) {
+            Map<String, Object> map = (Map<String, Object>) parameter;
+
+            JsonObjectBuilder jsonObject = Json.createObjectBuilder();
+
+            for (Map.Entry<String, Object> entry : map.entrySet()) {
+               String key = entry.getKey();
+
+               Object val = entry.getValue();
+
+               if (val != null) {
+                  if (val.getClass().isArray()) {
+                     JsonArray objectArray = toJSONArray((Object[]) val);
+                     jsonObject.add(key, objectArray);
+                  }
+                  else {
+                     addToObject(key, val, jsonObject);
+                  }
+               }
+            }
+            jsonArray.add(jsonObject);
+         }
+         else {
+            if (parameter != null) {
+               Class<?> clz = parameter.getClass();
+
+               if (clz.isArray()) {
+                  Object[] innerArray = (Object[]) parameter;
+
+                  if (innerArray instanceof CompositeData[]) {
+                     JsonArrayBuilder innerJsonArray = Json.createArrayBuilder();
+                     for (Object data : innerArray) {
+                        String s = Base64.encodeObject((CompositeDataSupport) data);
+                        innerJsonArray.add(s);
+                     }
+                     JsonObjectBuilder jsonObject = Json.createObjectBuilder();
+                     jsonObject.add(CompositeData.class.getName(), innerJsonArray);
+                     jsonArray.add(jsonObject);
+                  }
+                  else {
+                     jsonArray.add(toJSONArray(innerArray));
+                  }
+               }
+               else {
+                  addToArray(parameter, jsonArray);
+               }
+            }
+            else {
+               jsonArray.addNull();
+            }
+         }
+      }
+      return jsonArray.build();
+   }
+
+   public static Object[] fromJsonArray(final JsonArray jsonArray) throws Exception {
+      Object[] array = new Object[jsonArray.size()];
+
+      for (int i = 0; i < jsonArray.size(); i++) {
+         Object val = jsonArray.get(i);
+
+         if (val instanceof JsonArray) {
+            Object[] inner = fromJsonArray((JsonArray) val);
+
+            array[i] = inner;
+         }
+         else if (val instanceof JsonObject) {
+            JsonObject jsonObject = (JsonObject) val;
+
+            Map<String, Object> map = new HashMap<>();
+
+            Set<String> keys = jsonObject.keySet();
+
+            for (String key : keys) {
+               Object innerVal = jsonObject.get(key);
+
+               if (innerVal instanceof JsonArray) {
+                  innerVal = fromJsonArray(((JsonArray) innerVal));
+               }
+               else if (innerVal instanceof JsonObject) {
+                  Map<String, Object> innerMap = new HashMap<>();
+                  JsonObject o = (JsonObject) innerVal;
+                  Set<String> innerKeys = o.keySet();
+                  for (String k : innerKeys) {
+                     innerMap.put(k, o.get(k));
+                  }
+                  innerVal = innerMap;
+               }
+               else if (innerVal instanceof JsonNumber) {
+                  JsonNumber jsonNumber = (JsonNumber)innerVal;
+                  innerVal = jsonNumber.longValue();
+               }
+               if (CompositeData.class.getName().equals(key)) {
+                  Object[] data = (Object[]) innerVal;
+                  CompositeData[] cds = new CompositeData[data.length];
+                  for (int i1 = 0; i1 < data.length; i1++) {
+                     ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(Base64.decode((data[i1].toString()))));
+                     cds[i1] = (CompositeDataSupport) ois.readObject();
+                  }
+                  innerVal = cds;
+               }
+
+               map.put(key, innerVal);
+            }
+
+            array[i] = map;
+         }
+         else {
+            if (val == JsonObject.NULL) {
+               array[i] = null;
+            }
+            else {
+               array[i] = val;
+            }
+         }
+      }
+
+      return array;
+   }
+
+   public static void addToObject(final String key, final Object param, final JsonObjectBuilder jsonObjectBuilder) {
+      if (param instanceof Integer) {
+         jsonObjectBuilder.add(key, (Integer) param);
+      }
+      else if (param instanceof Long) {
+         jsonObjectBuilder.add(key, (Long) param);
+      }
+      else if (param instanceof Double) {
+         jsonObjectBuilder.add(key, (Double) param);
+      }
+      else if (param instanceof String) {
+         jsonObjectBuilder.add(key, (String) param);
+      }
+      else if (param instanceof Boolean) {
+         jsonObjectBuilder.add(key, (Boolean) param);
+      }
+      else if (param instanceof Map) {
+         JsonObject mapObject = toJsonObject((Map<String,Object>) param);
+         jsonObjectBuilder.add(key, mapObject);
+      }
+      else if (param instanceof Short) {
+         jsonObjectBuilder.add(key, (Short) param);
+      }
+      else if (param instanceof Byte) {
+         //??
+      }
+      else {
+         throw HornetQClientMessageBundle.BUNDLE.invalidManagementParam(param.getClass().getName());
+      }
+   }
+
+   public static void addToArray(final Object param, final JsonArrayBuilder jsonArrayBuilder) {
+      if (param instanceof Integer) {
+         jsonArrayBuilder.add((Integer) param);
+      }
+      else if (param instanceof Long) {
+         jsonArrayBuilder.add((Long) param);
+      }
+      else if (param instanceof Double) {
+         jsonArrayBuilder.add((Double) param);
+      }
+      else if (param instanceof String) {
+         jsonArrayBuilder.add((String) param);
+      }
+      else if (param instanceof Boolean) {
+         jsonArrayBuilder.add((Boolean) param);
+      }
+      else if (param instanceof Map) {
+         JsonObject mapObject = toJsonObject((Map<String,Object>) param);
+         jsonArrayBuilder.add(mapObject);
+      }
+      else if (param instanceof Short) {
+         jsonArrayBuilder.add((Short) param);
+      }
+      else if (param instanceof Byte) {
+         //??
+      }
+      else {
+         throw HornetQClientMessageBundle.BUNDLE.invalidManagementParam(param.getClass().getName());
+      }
+   }
+
+   public static JsonArray toJsonArray(List<String> strings) {
+      JsonArrayBuilder array = Json.createArrayBuilder();
+      if (strings != null) {
+         for (String connector : strings) {
+            array.add(connector);
+         }
+      }
+      return array.build();
+   }
+
+   public static JsonObject toJsonObject(Map<String, Object> map) {
+      JsonObjectBuilder jsonObjectBuilder = Json.createObjectBuilder();
+      for (Map.Entry<String, Object> entry : map.entrySet()) {
+         addToObject(entry.getKey(), entry.getValue(), jsonObjectBuilder);
+      }
+      return jsonObjectBuilder.build();
+   }
+
+   public static JsonArray readJsonArray(String jsonString) {
+      return Json.createReader(new StringReader(jsonString)).readArray();
+   }
+
+   public static JsonObject readJsonObject(String jsonString) {
+      return Json.createReader(new StringReader(jsonString)).readObject();
+   }
+
+   private JsonUtil() {
+   }
+}
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/api/core/management/AddressSettingsInfo.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/api/core/management/AddressSettingsInfo.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/api/core/management/AddressSettingsInfo.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/api/core/management/AddressSettingsInfo.java	2016-07-18 12:55:46.079854767 +0200
@@ -12,7 +12,9 @@
  */
 package org.hornetq.api.core.management;
 
-import org.hornetq.utils.json.JSONObject;
+import org.hornetq.api.core.JsonUtil;
+
+import javax.json.JsonObject;
 
 /**
  * A AddressSettingsInfo
@@ -56,27 +58,38 @@
 
    private final String slowConsumerPolicy;
 
+   //private final boolean autoCreateJmsQueues;
+
+   //private final boolean autoDeleteJmsQueues;
+
+   //private final boolean autoCreateJmsTopics;
+
+   //private final boolean autoDeleteJmsTopics;
+
    // Static --------------------------------------------------------
 
    public static AddressSettingsInfo from(final String jsonString) throws Exception
    {
-      JSONObject object = new JSONObject(jsonString);
+      JsonObject object = JsonUtil.readJsonObject(jsonString);
       return new AddressSettingsInfo(object.getString("addressFullMessagePolicy"),
-                                     object.getLong("maxSizeBytes"),
-                                     object.getInt("pageSizeBytes"),
-                                     object.getInt("pageCacheMaxSize"),
-                                     object.getInt("maxDeliveryAttempts"),
-                                     object.getLong("redeliveryDelay"),
-                                     object.getDouble("redeliveryMultiplier"),
-                                     object.getLong("maxRedeliveryDelay"),
-                                     object.getString("DLA"),
-                                     object.getString("expiryAddress"),
-                                     object.getBoolean("lastValueQueue"),
-                                     object.getLong("redistributionDelay"),
-                                     object.getBoolean("sendToDLAOnNoRoute"),
-                                     object.getLong("slowConsumerThreshold"),
-                                     object.getLong("slowConsumerCheckPeriod"),
-                                     object.getString("slowConsumerPolicy"));
+            object.getJsonNumber("maxSizeBytes").longValue(),
+            object.getInt("pageSizeBytes"),
+            object.getInt("pageCacheMaxSize"),
+            object.getInt("maxDeliveryAttempts"),
+            object.getJsonNumber("redeliveryDelay").longValue(),
+            object.getJsonNumber("redeliveryMultiplier").doubleValue(),
+            object.getJsonNumber("maxRedeliveryDelay").longValue(),
+            object.getString("DLA"), object.getString("expiryAddress"),
+            object.getBoolean("lastValueQueue"),
+            object.getJsonNumber("redistributionDelay").longValue(),
+            object.getBoolean("sendToDLAOnNoRoute"),
+            object.getJsonNumber("slowConsumerThreshold").longValue(),
+            object.getJsonNumber("slowConsumerCheckPeriod").longValue(),
+            object.getString("slowConsumerPolicy"));
+//            object.getBoolean("autoCreateJmsQueues"),
+//            object.getBoolean("autoDeleteJmsQueues"),
+//            object.getBoolean("autoCreateJmsTopics"),
+//            object.getBoolean("autoDeleteJmsTopics"));
    }
 
    // Constructors --------------------------------------------------
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/api/core/management/DayCounterInfo.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/api/core/management/DayCounterInfo.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/api/core/management/DayCounterInfo.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/api/core/management/DayCounterInfo.java	2016-07-18 10:21:09.860358387 +0200
@@ -12,11 +12,13 @@
  */
 package org.hornetq.api.core.management;
 
-import java.util.Arrays;
+import org.hornetq.api.core.JsonUtil;
 
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONException;
-import org.hornetq.utils.json.JSONObject;
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
 
 /**
  * Helper class to create Java Objects from the
@@ -33,18 +35,21 @@
 
    // Static --------------------------------------------------------
 
-   public static String toJSON(final DayCounterInfo[] infos) throws JSONException
-   {
-      JSONObject json = new JSONObject();
-      JSONArray counters = new JSONArray();
+   public static String toJSON(final DayCounterInfo[] infos) {
+      JsonObjectBuilder json = Json.createObjectBuilder();
+      JsonArrayBuilder counters = Json.createArrayBuilder();
       for (DayCounterInfo info : infos)
       {
-         JSONObject counter = new JSONObject();
-         counter.put("date", info.getDate());
-         counter.put("counters", Arrays.asList(info.getCounters()));
-         counters.put(counter);
+         JsonArrayBuilder counter = Json.createArrayBuilder();
+         for (int c : info.getCounters()) {
+            counter.add(c);
+         }
+         JsonObjectBuilder dci = Json.createObjectBuilder()
+            .add("date", info.getDate())
+            .add("counters", counter);
+         counters.add(dci);
       }
-      json.put("dayCounters", counters);
+      json.add("dayCounters", counters);
       return json.toString();
    }
 
@@ -52,16 +57,14 @@
     * Returns an array of RoleInfo corresponding to the JSON serialization returned
     * by {@link QueueControl#listMessageCounterHistory()}.
     */
-   public static DayCounterInfo[] fromJSON(final String jsonString) throws JSONException
-   {
-      JSONObject json = new JSONObject(jsonString);
-      JSONArray dayCounters = json.getJSONArray("dayCounters");
-      DayCounterInfo[] infos = new DayCounterInfo[dayCounters.length()];
-      for (int i = 0; i < dayCounters.length(); i++)
-      {
+   public static DayCounterInfo[] fromJSON(final String jsonString) {
+      JsonObject json = JsonUtil.readJsonObject(jsonString);
+      JsonArray dayCounters = json.getJsonArray("dayCounters");
+      DayCounterInfo[] infos = new DayCounterInfo[dayCounters.size()];
+      for (int i = 0; i < dayCounters.size(); i++) {
 
-         JSONObject counter = (JSONObject)dayCounters.get(i);
-         JSONArray hour = (JSONArray)counter.getJSONArray("counters").get(0);
+         JsonObject counter = (JsonObject) dayCounters.get(i);
+         JsonArray hour = (JsonArray) counter.getJsonArray("counters").get(0);
          int[] hourCounters = new int[24];
          for (int j = 0; j < 24; j++)
          {
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/api/core/management/ManagementHelper.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/api/core/management/ManagementHelper.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/api/core/management/ManagementHelper.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/api/core/management/ManagementHelper.java	2016-07-18 10:28:26.786434847 +0200
@@ -17,11 +17,12 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import javax.json.JsonArray;
+
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.api.core.Message;
 import org.hornetq.api.core.SimpleString;
 import org.hornetq.core.client.HornetQClientMessageBundle;
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
 
 /**
  * Helper class to use HornetQ Core messages to manage server resources.
@@ -136,7 +137,7 @@
 
       if (parameters != null)
       {
-         JSONArray jsonArray = ManagementHelper.toJSONArray(parameters);
+         JsonArray jsonArray = JsonUtil.toJSONArray(parameters);
 
          paramString = jsonArray.toString();
       }
@@ -148,154 +149,6 @@
       message.getBodyBuffer().writeNullableSimpleString(SimpleString.toSimpleString(paramString));
    }
 
-   private static JSONArray toJSONArray(final Object[] array) throws Exception
-   {
-      JSONArray jsonArray = new JSONArray();
-
-      for (Object parameter : array)
-      {
-         if (parameter instanceof Map)
-         {
-            Map<String, Object> map = (Map<String, Object>) parameter;
-
-            JSONObject jsonObject = new JSONObject();
-
-            for (Map.Entry<String, Object> entry : map.entrySet())
-            {
-               String key = entry.getKey();
-
-               Object val = entry.getValue();
-
-               if (val != null)
-               {
-                  if (val.getClass().isArray())
-                  {
-                     val = ManagementHelper.toJSONArray((Object[]) val);
-                  }
-                  else
-                  {
-                     ManagementHelper.checkType(val);
-                  }
-               }
-
-               jsonObject.put(key, val);
-            }
-
-            jsonArray.put(jsonObject);
-         }
-         else
-         {
-            if (parameter != null)
-            {
-               Class<?> clz = parameter.getClass();
-
-               if (clz.isArray())
-               {
-                  Object[] innerArray = (Object[]) parameter;
-
-                  jsonArray.put(ManagementHelper.toJSONArray(innerArray));
-               }
-               else
-               {
-                  ManagementHelper.checkType(parameter);
-
-                  jsonArray.put(parameter);
-               }
-            }
-            else
-            {
-               jsonArray.put((Object) null);
-            }
-         }
-      }
-
-      return jsonArray;
-   }
-
-   private static Object[] fromJSONArray(final JSONArray jsonArray) throws Exception
-   {
-      Object[] array = new Object[jsonArray.length()];
-
-      for (int i = 0; i < jsonArray.length(); i++)
-      {
-         Object val = jsonArray.get(i);
-
-         if (val instanceof JSONArray)
-         {
-            Object[] inner = ManagementHelper.fromJSONArray((JSONArray) val);
-
-            array[i] = inner;
-         }
-         else if (val instanceof JSONObject)
-         {
-            JSONObject jsonObject = (JSONObject) val;
-
-            Map<String, Object> map = new HashMap<String, Object>();
-
-            Iterator<String> iter = jsonObject.keys();
-
-            while (iter.hasNext())
-            {
-               String key = iter.next();
-
-               Object innerVal = jsonObject.get(key);
-
-               if (innerVal instanceof JSONArray)
-               {
-                  innerVal = ManagementHelper.fromJSONArray(((JSONArray) innerVal));
-               }
-               else if (innerVal instanceof JSONObject)
-               {
-                  Map<String, Object> innerMap = new HashMap<String, Object>();
-                  JSONObject o = (JSONObject) innerVal;
-                  Iterator it = o.keys();
-                  while (it.hasNext())
-                  {
-                     String k = (String) it.next();
-                     innerMap.put(k, o.get(k));
-                  }
-                  innerVal = innerMap;
-               }
-               else if (innerVal instanceof Integer)
-               {
-                  innerVal = ((Integer) innerVal).longValue();
-               }
-
-               map.put(key, innerVal);
-            }
-
-            array[i] = map;
-         }
-         else
-         {
-            if (val == JSONObject.NULL)
-            {
-               array[i] = null;
-            }
-            else
-            {
-               array[i] = val;
-            }
-         }
-      }
-
-      return array;
-   }
-
-   private static void checkType(final Object param)
-   {
-      if (param instanceof Integer == false && param instanceof Long == false &&
-         param instanceof Double == false &&
-         param instanceof String == false &&
-         param instanceof Boolean == false &&
-         param instanceof Map == false &&
-         param instanceof Byte == false &&
-         param instanceof Short == false)
-      {
-         throw HornetQClientMessageBundle.BUNDLE.invalidManagementParam(param.getClass().getName());
-      }
-   }
-
    /**
     * Used by HornetQ management service.
     */
@@ -306,9 +159,9 @@
 
       if (jsonString != null)
       {
-         JSONArray jsonArray = new JSONArray(jsonString);
+         JsonArray jsonArray = JsonUtil.readJsonArray(jsonString);
 
-         return ManagementHelper.fromJSONArray(jsonArray);
+         return JsonUtil.fromJsonArray(jsonArray);
       }
       else
       {
@@ -343,7 +196,7 @@
       {
          // Result is stored in body, also encoded as JSON array of length 1
 
-         JSONArray jsonArray = ManagementHelper.toJSONArray(new Object[]{result});
+         JsonArray jsonArray = JsonUtil.toJSONArray(new Object[]{result});
 
          resultString = jsonArray.toString();
       }
@@ -368,11 +221,8 @@
 
       if (jsonString != null)
       {
-         JSONArray jsonArray = new JSONArray(jsonString);
-
-         Object[] res = ManagementHelper.fromJSONArray(jsonArray);
-
-         return res;
+         JsonArray jsonArray = JsonUtil.readJsonArray(jsonString);
+         return JsonUtil.fromJsonArray(jsonArray);
       }
       else
       {
@@ -416,43 +266,6 @@
       return false;
    }
 
-   /**
-    * Used by HornetQ management service.
-    */
-   public static Map<String, Object> fromCommaSeparatedKeyValues(final String str) throws Exception
-   {
-      if (str == null || str.trim().length() == 0)
-      {
-         return Collections.emptyMap();
-      }
-
-      // create a JSON array with 1 object:
-      JSONArray array = new JSONArray("[{" + str + "}]");
-      Map<String, Object> params = (Map<String, Object>) ManagementHelper.fromJSONArray(array)[0];
-      return params;
-   }
-
-   /**
-    * Used by HornetQ management service.
-    */
-   public static Object[] fromCommaSeparatedArrayOfCommaSeparatedKeyValues(final String str) throws Exception
-   {
-      if (str == null || str.trim().length() == 0)
-      {
-         return new Object[0];
-      }
-
-      String s = str;
-
-      // if there is a single item, we wrap it in to make it a JSON object
-      if (!s.trim().startsWith("{"))
-      {
-         s = "{" + s + "}";
-      }
-      JSONArray array = new JSONArray("[" + s + "]");
-      return ManagementHelper.fromJSONArray(array);
-   }
-
    private ManagementHelper()
    {
    }
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/api/core/management/RoleInfo.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/api/core/management/RoleInfo.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/api/core/management/RoleInfo.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/api/core/management/RoleInfo.java	2016-07-18 12:52:17.675724534 +0200
@@ -12,8 +12,10 @@
  */
 package org.hornetq.api.core.management;
 
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
+import org.hornetq.api.core.JsonUtil;
+
+import javax.json.JsonArray;
+import javax.json.JsonObject;
 
 /**
  * Helper class to create Java Objects from the
@@ -39,25 +41,27 @@
 
    private final boolean manage;
 
+//  private final boolean browse;
+
    /**
     * Returns an array of RoleInfo corresponding to the JSON serialization returned
     * by {@link AddressControl#getRolesAsJSON()}.
     */
    public static RoleInfo[] from(final String jsonString) throws Exception
    {
-      JSONArray array = new JSONArray(jsonString);
-      RoleInfo[] roles = new RoleInfo[array.length()];
-      for (int i = 0; i < array.length(); i++)
-      {
-         JSONObject r = array.getJSONObject(i);
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      RoleInfo[] roles = new RoleInfo[array.size()];
+      for (int i = 0; i < array.size(); i++) {
+         JsonObject r = array.getJsonObject(i);
          RoleInfo role = new RoleInfo(r.getString("name"),
-                                      r.getBoolean("send"),
-                                      r.getBoolean("consume"),
-                                      r.getBoolean("createDurableQueue"),
-                                      r.getBoolean("deleteDurableQueue"),
-                                      r.getBoolean("createNonDurableQueue"),
-                                      r.getBoolean("deleteNonDurableQueue"),
-                                      r.getBoolean("manage"));
+               r.getBoolean("send"),
+               r.getBoolean("consume"),
+               r.getBoolean("createDurableQueue"),
+               r.getBoolean("deleteDurableQueue"),
+               r.getBoolean("createNonDurableQueue"),
+               r.getBoolean("deleteNonDurableQueue"),
+               r.getBoolean("manage"));
+//               r.getBoolean("browse"));
          roles[i] = role;
       }
       return roles;
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/api/core/TransportConfiguration.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/api/core/TransportConfiguration.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/api/core/TransportConfiguration.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/api/core/TransportConfiguration.java	2016-07-18 12:42:27.915665579 +0200
@@ -20,6 +20,9 @@
 import org.hornetq.core.remoting.impl.netty.TransportConstants;
 import org.hornetq.utils.UUIDGenerator;
 
+import javax.json.Json;
+import javax.json.JsonObject;
+
 /**
  * A TransportConfiguration is used by a client to specify connections to a server and its backup if
  * one exists.
@@ -47,6 +50,8 @@
 
    private Map<String, Object> params;
 
+   private Map<String, Object> extraProps;
+
    private static final byte TYPE_BOOLEAN = 0;
 
    private static final byte TYPE_INT = 1;
@@ -54,6 +59,15 @@
    private static final byte TYPE_LONG = 2;
 
    private static final byte TYPE_STRING = 3;
+ 
+   public JsonObject toJson() {
+      return Json.createObjectBuilder()
+            .add("name", name)
+            .add("factoryClassName", factoryClassName)
+            .add("params", JsonUtil.toJsonObject(params))
+            .add("extraProps", JsonUtil.toJsonObject(extraProps))
+            .build();
+   }
 
    /**
     * Utility method for splitting a comma separated list of hosts
@@ -402,4 +416,4 @@
    {
       return str.replace('.', '-');
    }
-}
\ Manca newline alla fine del file
+}
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/core/security/Role.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/core/security/Role.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/core/security/Role.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/core/security/Role.java	2016-07-18 13:11:48.548270472 +0200
@@ -13,6 +13,8 @@
 package org.hornetq.core.security;
 
 import java.io.Serializable;
+import javax.json.Json;
+import javax.json.JsonObject;
 
 /**
  * A role is used by the security store to define access rights and is configured on a connection factory or an address.
@@ -39,6 +41,22 @@
 
    private final boolean manage;
 
+   //private final boolean browse;
+
+   public JsonObject toJson() {
+      return Json.createObjectBuilder()
+            .add("name", name)
+            .add("send", send)
+            .add("consume", consume)
+            .add("createDurableQueue", createDurableQueue)
+            .add("deleteDurableQueue", deleteDurableQueue)
+            .add("createNonDurableQueue", createNonDurableQueue)
+            .add("deleteNonDurableQueue", deleteNonDurableQueue)
+            .add("manage", manage)
+            .build();
+            //.add("browse", browse)
+   }
+
    public Role(final String name,
                final boolean send,
                final boolean consume,
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONArray.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONArray.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONArray.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONArray.java	1970-01-01 01:00:00.000000000 +0100
@@ -1,1034 +0,0 @@
-/*
- * Copyright 2005-2014 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-/*
-Copyright (c) 2002 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-package org.hornetq.utils.json;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * A JSONArray is an ordered sequence of values. Its external text form is a
- * string wrapped in square brackets with commas separating the values. The
- * internal form is an object having <code>get</code> and <code>opt</code>
- * methods for accessing the values by index, and <code>put</code> methods for
- * adding or replacing values. The values can be any of these types:
- * <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>,
- * <code>Number</code>, {@code string}, or the
- * <code>JSONObject.NULL object</code>.
- * <p>
- * The constructor can convert a JSON text into a Java object. The
- * <code>toString</code> method converts to JSON text.
- * <p>
- * A <code>get</code> method returns a value if one can be found, and throws an
- * exception if one cannot be found. An <code>opt</code> method returns a
- * default value instead of throwing an exception, and so is useful for
- * obtaining optional values.
- * <p>
- * The generic <code>get()</code> and <code>opt()</code> methods return an
- * object which you can cast or query for type. There are also typed
- * <code>get</code> and <code>opt</code> methods that do type checking and type
- * coercion for you.
- * <p>
- * The texts produced by the <code>toString</code> methods strictly conform to
- * JSON syntax rules. The constructors are more forgiving in the texts they will
- * accept:
- * <ul>
- * <li>An extra <code>,</code>&nbsp;<small>(comma)</small> may appear just
- *     before the closing bracket.</li>
- * <li>The {@code null} value will be inserted when there
- *     is <code>,</code>&nbsp;<small>(comma)</small> elision.</li>
- * <li>Strings may be quoted with <code>'</code>&nbsp;<small>(single
- *     quote)</small>.</li>
- * <li>Strings do not need to be quoted at all if they do not begin with a quote
- *     or single quote, and if they do not contain leading or trailing spaces,
- *     and if they do not contain any of these characters:
- *     <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers
- *     and if they are not the reserved words <code>true</code>,
- *     <code>false</code>, or {@code null}.</li>
- * <li>Values can be separated by <code>;</code> <small>(semicolon)</small> as
- *     well as by <code>,</code> <small>(comma)</small>.</li>
- * <li>Numbers may have the <code>0-</code> <small>(octal)</small> or
- *     <code>0x-</code> <small>(hex)</small> prefix.</li>
- * </ul>
-
- * @author JSON.org
- * @version 2009-04-13
- */
-public class JSONArray
-{
-
-   /**
-    * The arrayList where the JSONArray's properties are kept.
-    */
-   private final ArrayList<Object> myArrayList;
-
-   /**
-    * Construct an empty JSONArray.
-    */
-   public JSONArray()
-   {
-      myArrayList = new ArrayList<Object>();
-   }
-
-   /**
-    * Construct a JSONArray from a JSONTokener.
-    * @param x A JSONTokener
-    * @throws JSONException If there is a syntax error.
-    */
-   public JSONArray(final JSONTokener x) throws JSONException
-   {
-      this();
-      char c = x.nextClean();
-      char q;
-      if (c == '[')
-      {
-         q = ']';
-      }
-      else if (c == '(')
-      {
-         q = ')';
-      }
-      else
-      {
-         throw x.syntaxError("A JSONArray text must start with '['");
-      }
-      if (x.nextClean() == ']')
-      {
-         return;
-      }
-      x.back();
-      for (;;)
-      {
-         if (x.nextClean() == ',')
-         {
-            x.back();
-            myArrayList.add(null);
-         }
-         else
-         {
-            x.back();
-            myArrayList.add(x.nextValue());
-         }
-         c = x.nextClean();
-         switch (c)
-         {
-            case ';':
-            case ',':
-               if (x.nextClean() == ']')
-               {
-                  return;
-               }
-               x.back();
-               break;
-            case ']':
-            case ')':
-               if (q != c)
-               {
-                  throw x.syntaxError("Expected a '" + Character.valueOf(q) + "'");
-               }
-               return;
-            default:
-               throw x.syntaxError("Expected a ',' or ']'");
-         }
-      }
-   }
-
-   /**
-    * Construct a JSONArray from a source JSON text.
-    * @param source     A string that begins with
-    * <code>[</code>&nbsp;<small>(left bracket)</small>
-    *  and ends with <code>]</code>&nbsp;<small>(right bracket)</small>.
-    *  @throws JSONException If there is a syntax error.
-    */
-   public JSONArray(final String source) throws JSONException
-   {
-      this(new JSONTokener(source));
-   }
-
-   /**
-    * Construct a JSONArray from a Collection.
-    * @param collection     A Collection.
-    */
-   public JSONArray(final Collection collection)
-   {
-      myArrayList = collection == null ? new ArrayList<Object>() : new ArrayList<Object>(collection);
-   }
-
-   /**
-    * Construct a JSONArray from a collection of beans.
-    * The collection should have Java Beans.
-    */
-   public JSONArray(final Collection collection, final boolean includeSuperClass)
-   {
-      myArrayList = collection == null ? new ArrayList<Object>() : new ArrayList<Object>(collection.size());
-      if (collection != null)
-      {
-         Iterator<Object> iter = collection.iterator();
-         while (iter.hasNext())
-         {
-            Object o = iter.next();
-            if (o instanceof Map<?, ?>)
-            {
-               myArrayList.add(new JSONObject((Map<?, ?>)o, includeSuperClass));
-            }
-            else if (!JSONObject.isStandardProperty(o.getClass()))
-            {
-               myArrayList.add(new JSONObject(o, includeSuperClass));
-            }
-            else
-            {
-               myArrayList.add(o);
-            }
-         }
-      }
-   }
-
-   /**
-    * Construct a JSONArray from an array
-    * @throws JSONException If not an array.
-    */
-   public JSONArray(final Object array) throws JSONException
-   {
-      this();
-      if (array.getClass().isArray())
-      {
-         int length = Array.getLength(array);
-         for (int i = 0; i < length; i += 1)
-         {
-            this.put(Array.get(array, i));
-         }
-      }
-      else
-      {
-         throw new JSONException("JSONArray initial value should be a string or collection or array.");
-      }
-   }
-
-   /**
-    * Construct a JSONArray from an array with a bean.
-    * The array should have Java Beans.
-    *
-    * @throws JSONException If not an array.
-    */
-   public JSONArray(final Object array, final boolean includeSuperClass) throws JSONException
-   {
-      this();
-      if (array.getClass().isArray())
-      {
-         int length = Array.getLength(array);
-         for (int i = 0; i < length; i += 1)
-         {
-            Object o = Array.get(array, i);
-            if (JSONObject.isStandardProperty(o.getClass()))
-            {
-               myArrayList.add(o);
-            }
-            else
-            {
-               myArrayList.add(new JSONObject(o, includeSuperClass));
-            }
-         }
-      }
-      else
-      {
-         throw new JSONException("JSONArray initial value should be a string or collection or array.");
-      }
-   }
-
-   /**
-    * Get the object value associated with an index.
-    * @param index
-    *  The index must be between 0 and length() - 1.
-    * @return An object value.
-    * @throws JSONException If there is no value for the index.
-    */
-   public Object get(final int index) throws JSONException
-   {
-      Object o = opt(index);
-      if (o == null)
-      {
-         throw new JSONException("JSONArray[" + index + "] not found.");
-      }
-      return o;
-   }
-
-   /**
-    * Get the boolean value associated with an index.
-    * The string values "true" and "false" are converted to boolean.
-    *
-    * @param index The index must be between 0 and length() - 1.
-    * @return      The truth.
-    * @throws JSONException If there is no value for the index or if the
-    *  value is not convertable to boolean.
-    */
-   public boolean getBoolean(final int index) throws JSONException
-   {
-      Object o = get(index);
-      if (o.equals(Boolean.FALSE) || o instanceof String && ((String)o).equalsIgnoreCase("false"))
-      {
-         return false;
-      }
-      else if (o.equals(Boolean.TRUE) || o instanceof String && ((String)o).equalsIgnoreCase("true"))
-      {
-         return true;
-      }
-      throw new JSONException("JSONArray[" + index + "] is not a Boolean.");
-   }
-
-   /**
-    * Get the double value associated with an index.
-    *
-    * @param index The index must be between 0 and length() - 1.
-    * @return      The value.
-    * @throws   JSONException If the key is not found or if the value cannot
-    *  be converted to a number.
-    */
-   public double getDouble(final int index) throws JSONException
-   {
-      Object o = get(index);
-      try
-      {
-         return o instanceof Number ? ((Number)o).doubleValue() : Double.valueOf((String)o).doubleValue();
-      }
-      catch (Exception e)
-      {
-         throw new JSONException("JSONArray[" + index + "] is not a number.");
-      }
-   }
-
-   /**
-    * Get the int value associated with an index.
-    *
-    * @param index The index must be between 0 and length() - 1.
-    * @return      The value.
-    * @throws   JSONException If the key is not found or if the value cannot
-    *  be converted to a number.
-    *  if the value cannot be converted to a number.
-    */
-   public int getInt(final int index) throws JSONException
-   {
-      Object o = get(index);
-      return o instanceof Number ? ((Number)o).intValue() : (int)getDouble(index);
-   }
-
-   /**
-    * Get the JSONArray associated with an index.
-    * @param index The index must be between 0 and length() - 1.
-    * @return      A JSONArray value.
-    * @throws JSONException If there is no value for the index. or if the
-    * value is not a JSONArray
-    */
-   public JSONArray getJSONArray(final int index) throws JSONException
-   {
-      Object o = get(index);
-      if (o instanceof JSONArray)
-      {
-         return (JSONArray)o;
-      }
-      throw new JSONException("JSONArray[" + index + "] is not a JSONArray.");
-   }
-
-   /**
-    * Get the JSONObject associated with an index.
-    * @param index subscript
-    * @return      A JSONObject value.
-    * @throws JSONException If there is no value for the index or if the
-    * value is not a JSONObject
-    */
-   public JSONObject getJSONObject(final int index) throws JSONException
-   {
-      Object o = get(index);
-      if (o instanceof JSONObject)
-      {
-         return (JSONObject)o;
-      }
-      throw new JSONException("JSONArray[" + index + "] is not a JSONObject.");
-   }
-
-   /**
-    * Get the long value associated with an index.
-    *
-    * @param index The index must be between 0 and length() - 1.
-    * @return      The value.
-    * @throws   JSONException If the key is not found or if the value cannot
-    *  be converted to a number.
-    */
-   public long getLong(final int index) throws JSONException
-   {
-      Object o = get(index);
-      return o instanceof Number ? ((Number)o).longValue() : (long)getDouble(index);
-   }
-
-   /**
-    * Get the string associated with an index.
-    * @param index The index must be between 0 and length() - 1.
-    * @return      A string value.
-    * @throws JSONException If there is no value for the index.
-    */
-   public String getString(final int index) throws JSONException
-   {
-      return get(index).toString();
-   }
-
-   /**
-    * Determine if the value is null.
-    * @param index The index must be between 0 and length() - 1.
-    * @return true if the value at the index is null, or if there is no value.
-    */
-   public boolean isNull(final int index)
-   {
-      return JSONObject.NULL.equals(opt(index));
-   }
-
-   /**
-    * Make a string from the contents of this JSONArray. The
-    * <code>separator</code> string is inserted between each element.
-    * Warning: This method assumes that the data structure is acyclical.
-    * @param separator A string that will be inserted between the elements.
-    * @return a string.
-    * @throws JSONException If the array contains an invalid number.
-    */
-   public String join(final String separator) throws JSONException
-   {
-      int len = length();
-      StringBuffer sb = new StringBuffer();
-
-      for (int i = 0; i < len; i += 1)
-      {
-         if (i > 0)
-         {
-            sb.append(separator);
-         }
-         sb.append(JSONObject.valueToString(myArrayList.get(i)));
-      }
-      return sb.toString();
-   }
-
-   /**
-    * Get the number of elements in the JSONArray, included nulls.
-    *
-    * @return The length (or size).
-    */
-   public int length()
-   {
-      return myArrayList.size();
-   }
-
-   /**
-    * Get the optional object value associated with an index.
-    * @param index The index must be between 0 and length() - 1.
-    * @return      An object value, or null if there is no
-    *              object at that index.
-    */
-   public Object opt(final int index)
-   {
-      return index < 0 || index >= length() ? null : myArrayList.get(index);
-   }
-
-   /**
-    * Get the optional boolean value associated with an index.
-    * It returns false if there is no value at that index,
-    * or if the value is not Boolean.TRUE or the String "true".
-    *
-    * @param index The index must be between 0 and length() - 1.
-    * @return      The truth.
-    */
-   public boolean optBoolean(final int index)
-   {
-      return optBoolean(index, false);
-   }
-
-   /**
-    * Get the optional boolean value associated with an index.
-    * It returns the defaultValue if there is no value at that index or if
-    * it is not a Boolean or the String "true" or "false" (case insensitive).
-    *
-    * @param index The index must be between 0 and length() - 1.
-    * @param defaultValue     A boolean default.
-    * @return      The truth.
-    */
-   public boolean optBoolean(final int index, final boolean defaultValue)
-   {
-      try
-      {
-         return getBoolean(index);
-      }
-      catch (Exception e)
-      {
-         return defaultValue;
-      }
-   }
-
-   /**
-    * Get the optional double value associated with an index.
-    * NaN is returned if there is no value for the index,
-    * or if the value is not a number and cannot be converted to a number.
-    *
-    * @param index The index must be between 0 and length() - 1.
-    * @return      The value.
-    */
-   public double optDouble(final int index)
-   {
-      return optDouble(index, Double.NaN);
-   }
-
-   /**
-    * Get the optional double value associated with an index.
-    * The defaultValue is returned if there is no value for the index,
-    * or if the value is not a number and cannot be converted to a number.
-    *
-    * @param index subscript
-    * @param defaultValue     The default value.
-    * @return      The value.
-    */
-   public double optDouble(final int index, final double defaultValue)
-   {
-      try
-      {
-         return getDouble(index);
-      }
-      catch (Exception e)
-      {
-         return defaultValue;
-      }
-   }
-
-   /**
-    * Get the optional int value associated with an index.
-    * Zero is returned if there is no value for the index,
-    * or if the value is not a number and cannot be converted to a number.
-    *
-    * @param index The index must be between 0 and length() - 1.
-    * @return      The value.
-    */
-   public int optInt(final int index)
-   {
-      return optInt(index, 0);
-   }
-
-   /**
-    * Get the optional int value associated with an index.
-    * The defaultValue is returned if there is no value for the index,
-    * or if the value is not a number and cannot be converted to a number.
-    * @param index The index must be between 0 and length() - 1.
-    * @param defaultValue     The default value.
-    * @return      The value.
-    */
-   public int optInt(final int index, final int defaultValue)
-   {
-      try
-      {
-         return getInt(index);
-      }
-      catch (Exception e)
-      {
-         return defaultValue;
-      }
-   }
-
-   /**
-    * Get the optional JSONArray associated with an index.
-    * @param index subscript
-    * @return      A JSONArray value, or null if the index has no value,
-    * or if the value is not a JSONArray.
-    */
-   public JSONArray optJSONArray(final int index)
-   {
-      Object o = opt(index);
-      return o instanceof JSONArray ? (JSONArray)o : null;
-   }
-
-   /**
-    * Get the optional JSONObject associated with an index.
-    * Null is returned if the key is not found, or null if the index has
-    * no value, or if the value is not a JSONObject.
-    *
-    * @param index The index must be between 0 and length() - 1.
-    * @return      A JSONObject value.
-    */
-   public JSONObject optJSONObject(final int index)
-   {
-      Object o = opt(index);
-      return o instanceof JSONObject ? (JSONObject)o : null;
-   }
-
-   /**
-    * Get the optional long value associated with an index.
-    * Zero is returned if there is no value for the index,
-    * or if the value is not a number and cannot be converted to a number.
-    *
-    * @param index The index must be between 0 and length() - 1.
-    * @return      The value.
-    */
-   public long optLong(final int index)
-   {
-      return optLong(index, 0);
-   }
-
-   /**
-    * Get the optional long value associated with an index.
-    * The defaultValue is returned if there is no value for the index,
-    * or if the value is not a number and cannot be converted to a number.
-    * @param index The index must be between 0 and length() - 1.
-    * @param defaultValue     The default value.
-    * @return      The value.
-    */
-   public long optLong(final int index, final long defaultValue)
-   {
-      try
-      {
-         return getLong(index);
-      }
-      catch (Exception e)
-      {
-         return defaultValue;
-      }
-   }
-
-   /**
-    * Get the optional string value associated with an index. It returns an
-    * empty string if there is no value at that index. If the value
-    * is not a string and is not null, then it is converted to a string.
-    *
-    * @param index The index must be between 0 and length() - 1.
-    * @return      A String value.
-    */
-   public String optString(final int index)
-   {
-      return optString(index, "");
-   }
-
-   /**
-    * Get the optional string associated with an index.
-    * The defaultValue is returned if the key is not found.
-    *
-    * @param index The index must be between 0 and length() - 1.
-    * @param defaultValue     The default value.
-    * @return      A String value.
-    */
-   public String optString(final int index, final String defaultValue)
-   {
-      Object o = opt(index);
-      return o != null ? o.toString() : defaultValue;
-   }
-
-   /**
-    * Append a boolean value. This increases the array's length by one.
-    *
-    * @param value A boolean value.
-    * @return this.
-    */
-   public JSONArray put(final boolean value)
-   {
-      put(value ? Boolean.TRUE : Boolean.FALSE);
-      return this;
-   }
-
-   /**
-    * Put a value in the JSONArray, where the value will be a
-    * JSONArray which is produced from a Collection.
-    * @param value A Collection value.
-    * @return      this.
-    */
-   public JSONArray put(final Collection value)
-   {
-      put(new JSONArray(value));
-      return this;
-   }
-
-   /**
-    * Append a double value. This increases the array's length by one.
-    *
-    * @param value A double value.
-    * @throws JSONException if the value is not finite.
-    * @return this.
-    */
-   public JSONArray put(final double value) throws JSONException
-   {
-      Double d = new Double(value);
-      JSONObject.testValidity(d);
-      put(d);
-      return this;
-   }
-
-   /**
-    * Append an int value. This increases the array's length by one.
-    *
-    * @param value An int value.
-    * @return this.
-    */
-   public JSONArray put(final int value)
-   {
-      put(Integer.valueOf(value));
-      return this;
-   }
-
-   /**
-    * Append an long value. This increases the array's length by one.
-    *
-    * @param value A long value.
-    * @return this.
-    */
-   public JSONArray put(final long value)
-   {
-      put(Long.valueOf(value));
-      return this;
-   }
-
-   /**
-    * Put a value in the JSONArray, where the value will be a
-    * JSONObject which is produced from a Map.
-    * @param value A Map value.
-    * @return      this.
-    */
-   public JSONArray put(final Map value)
-   {
-      put(new JSONObject(value));
-      return this;
-   }
-
-   /**
-    * Append an object value. This increases the array's length by one.
-    * @param value An object value.  The value should be a
-    *  Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
-    *  JSONObject.NULL object.
-    * @return this.
-    */
-   public JSONArray put(final Object value)
-   {
-      myArrayList.add(value);
-      return this;
-   }
-
-   /**
-    * Put or replace a boolean value in the JSONArray. If the index is greater
-    * than the length of the JSONArray, then null elements will be added as
-    * necessary to pad it out.
-    * @param index The subscript.
-    * @param value A boolean value.
-    * @return this.
-    * @throws JSONException If the index is negative.
-    */
-   public JSONArray put(final int index, final boolean value) throws JSONException
-   {
-      put(index, value ? Boolean.TRUE : Boolean.FALSE);
-      return this;
-   }
-
-   /**
-    * Put a value in the JSONArray, where the value will be a
-    * JSONArray which is produced from a Collection.
-    * @param index The subscript.
-    * @param value A Collection value.
-    * @return      this.
-    * @throws JSONException If the index is negative or if the value is
-    * not finite.
-    */
-   public JSONArray put(final int index, final Collection value) throws JSONException
-   {
-      put(index, new JSONArray(value));
-      return this;
-   }
-
-   /**
-    * Put or replace a double value. If the index is greater than the length of
-    *  the JSONArray, then null elements will be added as necessary to pad
-    *  it out.
-    * @param index The subscript.
-    * @param value A double value.
-    * @return this.
-    * @throws JSONException If the index is negative or if the value is
-    * not finite.
-    */
-   public JSONArray put(final int index, final double value) throws JSONException
-   {
-      put(index, new Double(value));
-      return this;
-   }
-
-   /**
-    * Put or replace an int value. If the index is greater than the length of
-    *  the JSONArray, then null elements will be added as necessary to pad
-    *  it out.
-    * @param index The subscript.
-    * @param value An int value.
-    * @return this.
-    * @throws JSONException If the index is negative.
-    */
-   public JSONArray put(final int index, final int value) throws JSONException
-   {
-      put(index, Integer.valueOf(value));
-      return this;
-   }
-
-   /**
-    * Put or replace a long value. If the index is greater than the length of
-    *  the JSONArray, then null elements will be added as necessary to pad
-    *  it out.
-    * @param index The subscript.
-    * @param value A long value.
-    * @return this.
-    * @throws JSONException If the index is negative.
-    */
-   public JSONArray put(final int index, final long value) throws JSONException
-   {
-      put(index, Long.valueOf(value));
-      return this;
-   }
-
-   /**
-    * Put a value in the JSONArray, where the value will be a
-    * JSONObject which is produced from a Map.
-    * @param index The subscript.
-    * @param value The Map value.
-    * @return      this.
-    * @throws JSONException If the index is negative or if the the value is
-    *  an invalid number.
-    */
-   public JSONArray put(final int index, final Map value) throws JSONException
-   {
-      put(index, new JSONObject(value));
-      return this;
-   }
-
-   /**
-    * Put or replace an object value in the JSONArray. If the index is greater
-    *  than the length of the JSONArray, then null elements will be added as
-    *  necessary to pad it out.
-    * @param index The subscript.
-    * @param value The value to put into the array. The value should be a
-    *  Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
-    *  JSONObject.NULL object.
-    * @return this.
-    * @throws JSONException If the index is negative or if the the value is
-    *  an invalid number.
-    */
-   public JSONArray put(final int index, final Object value) throws JSONException
-   {
-      JSONObject.testValidity(value);
-      if (index < 0)
-      {
-         throw new JSONException("JSONArray[" + index + "] not found.");
-      }
-      if (index < length())
-      {
-         myArrayList.set(index, value);
-      }
-      else
-      {
-         while (index != length())
-         {
-            put(JSONObject.NULL);
-         }
-         put(value);
-      }
-      return this;
-   }
-
-   /**
-    * Remove a index and close the hole.
-    * @param index The index of the element to be removed.
-    * @return The value that was associated with the index,
-    * or null if there was no value.
-    */
-   public Object remove(final int index)
-   {
-      Object o = opt(index);
-      myArrayList.remove(index);
-      return o;
-   }
-
-   /**
-    * Produce a JSONObject by combining a JSONArray of names with the values
-    * of this JSONArray.
-    * @param names A JSONArray containing a list of key strings. These will be
-    * paired with the values.
-    * @return A JSONObject, or null if there are no names or if this JSONArray
-    * has no values.
-    * @throws JSONException If any of the names are null.
-    */
-   public JSONObject toJSONObject(final JSONArray names) throws JSONException
-   {
-      if (names == null || names.length() == 0 || length() == 0)
-      {
-         return null;
-      }
-      JSONObject jo = new JSONObject();
-      for (int i = 0; i < names.length(); i += 1)
-      {
-         jo.put(names.getString(i), opt(i));
-      }
-      return jo;
-   }
-
-   /**
-    * Make a JSON text of this JSONArray. For compactness, no
-    * unnecessary whitespace is added. If it is not possible to produce a
-    * syntactically correct JSON text then null will be returned instead. This
-    * could occur if the array contains an invalid number.
-    * <p>
-    * Warning: This method assumes that the data structure is acyclical.
-    *
-    * @return a printable, displayable, transmittable
-    *  representation of the array.
-    */
-   @Override
-   public String toString()
-   {
-      try
-      {
-         return '[' + join(",") + ']';
-      }
-      catch (Exception e)
-      {
-         return "";
-      }
-   }
-
-   /**
-    * Make a pretty-printed JSON text of this JSONArray. Warning: This method assumes that the data
-    * structure is acyclical.
-    * @param indentFactor The number of spaces to add to each level of indentation.
-    * @return a printable, displayable, transmittable representation of the object, beginning with
-    *         <code>[</code>&nbsp;<small>(left bracket)</small> and ending with <code>]</code>
-    *         &nbsp;<small>(right bracket)</small>.
-    * @throws JSONException
-    */
-   public String toString(final int indentFactor) throws JSONException
-   {
-      return toString(indentFactor, 0);
-   }
-
-   /**
-    * Make a pretty-printed JSON text of this JSONArray. Warning: This method assumes that the data
-    * structure is acyclical.
-    * @param indentFactor The number of spaces to add to each level of indentation.
-    * @param indent The indention of the top level.
-    * @return a printable, displayable, transmittable representation of the array.
-    * @throws JSONException
-    */
-   String toString(final int indentFactor, final int indent) throws JSONException
-   {
-      int len = length();
-      if (len == 0)
-      {
-         return "[]";
-      }
-      int i;
-      StringBuffer sb = new StringBuffer("[");
-      if (len == 1)
-      {
-         sb.append(JSONObject.valueToString(myArrayList.get(0), indentFactor, indent));
-      }
-      else
-      {
-         int newindent = indent + indentFactor;
-         sb.append('\n');
-         for (i = 0; i < len; i += 1)
-         {
-            if (i > 0)
-            {
-               sb.append(",\n");
-            }
-            for (int j = 0; j < newindent; j += 1)
-            {
-               sb.append(' ');
-            }
-            sb.append(JSONObject.valueToString(myArrayList.get(i), indentFactor, newindent));
-         }
-         sb.append('\n');
-         for (i = 0; i < indent; i += 1)
-         {
-            sb.append(' ');
-         }
-      }
-      sb.append(']');
-      return sb.toString();
-   }
-
-   /**
-    * Write the contents of the JSONArray as JSON text to a writer.
-    * For compactness, no whitespace is added.
-    * <p>
-    * Warning: This method assumes that the data structure is acyclical.
-    *
-    * @return The writer.
-    * @throws JSONException
-    */
-   public Writer write(final Writer writer) throws JSONException
-   {
-      try
-      {
-         boolean b = false;
-         int len = length();
-
-         writer.write('[');
-
-         for (int i = 0; i < len; i += 1)
-         {
-            if (b)
-            {
-               writer.write(',');
-            }
-            Object v = myArrayList.get(i);
-            if (v instanceof JSONObject)
-            {
-               ((JSONObject)v).write(writer);
-            }
-            else if (v instanceof JSONArray)
-            {
-               ((JSONArray)v).write(writer);
-            }
-            else
-            {
-               writer.write(JSONObject.valueToString(v));
-            }
-            b = true;
-         }
-         writer.write(']');
-         return writer;
-      }
-      catch (IOException e)
-      {
-         throw new JSONException(e);
-      }
-   }
-}
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONException.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONException.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONException.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONException.java	1970-01-01 01:00:00.000000000 +0100
@@ -1,73 +0,0 @@
-/*
- * Copyright 2005-2014 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-/*
-Copyright (c) 2002 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-package org.hornetq.utils.json;
-
-/**
- * The JSONException is thrown by the JSON.org classes then things are amiss.
- * @author JSON.org
- * @version 2008-09-18
- */
-public class JSONException extends Exception
-{
-   /**
-   *
-   */
-   private static final long serialVersionUID = -3940674325153571604L;
-
-   private Throwable cause;
-
-   /**
-    * Constructs a JSONException with an explanatory message.
-    * @param message Detail about the reason for the exception.
-    */
-   public JSONException(final String message)
-   {
-      super(message);
-   }
-
-   public JSONException(final Throwable t)
-   {
-      super(t.getMessage());
-      cause = t;
-   }
-
-   @Override
-   public synchronized Throwable getCause()
-   {
-      return cause;
-   }
-}
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONObject.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONObject.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONObject.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONObject.java	1970-01-01 01:00:00.000000000 +0100
@@ -1,1751 +0,0 @@
-/*
- * Copyright 2005-2014 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-/*
-Copyright (c) 2002 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-package org.hornetq.utils.json;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeSet;
-
-/**
- * A JSONObject is an unordered collection of name/value pairs.
- * <p>
- * Its external form is a string wrapped in curly braces with colons between the names and values,
- * and commas between the values and names. The internal form is an object having <code>get</code>
- * and <code>opt</code> methods for accessing the values by name, and <code>put</code> methods for
- * adding or replacing values by name.
- * <p>
- * The values can be any of these types: <code>Boolean</code>, <code>JSONArray</code>,
- * <code>JSONObject</code>, <code>Number</code>, {@code string}, or the
- * <code>JSONObject.NULL</code> object. A JSONObject constructor can be used to convert an external
- * form JSON text into an internal form whose values can be retrieved with the <code>get</code> and
- * <code>opt</code> methods, or to convert values into a JSON text using the <code>put</code> and
- * <code>toString</code> methods. A <code>get</code> method returns a value if one can be found, and
- * throws an exception if one cannot be found. An <code>opt</code> method returns a default value
- * instead of throwing an exception, and so is useful for obtaining optional values.
- * <p>
- * The generic <code>get()</code> and <code>opt()</code> methods return an object, which you can
- * cast or query for type. There are also typed <code>get</code> and <code>opt</code> methods that
- * do type checking and type coercion for you.
- * <p>
- * The <code>put</code> methods adds values to an object. For example,
- *
- * <pre>
- * myString = new JSONObject().put(&quot;JSON&quot;, &quot;Hello, World!&quot;).toString();
- * </pre>
- *
- * produces the string <code>{"JSON": "Hello, World"}</code>.
- * <p>
- * The texts produced by the <code>toString</code> methods strictly conform to the JSON syntax
- * rules. The constructors are more forgiving in the texts they will accept:
- * <ul>
- * <li>An extra <code>,</code>&nbsp;<small>(comma)</small> may appear just before the closing brace.
- * </li>
- * <li>Strings may be quoted with <code>'</code>&nbsp;<small>(single quote)</small>.</li>
- * <li>Strings do not need to be quoted at all if they do not begin with a quote or single quote,
- * and if they do not contain leading or trailing spaces, and if they do not contain any of these
- * characters: <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers and if they
- * are not the reserved words <code>true</code>, <code>false</code>, or {@code null}.</li>
- * <li>Keys can be followed by <code>=</code> or <code>=&gt;</code> as well as by <code>:</code>.</li>
- * <li>Values can be followed by <code>;</code> <small>(semicolon)</small> as well as by
- * <code>,</code> <small>(comma)</small>.</li>
- * <li>Numbers may have the <code>0-</code> <small>(octal)</small> or <code>0x-</code>
- * <small>(hex)</small> prefix.</li>
- * </ul>
- * @author JSON.org
- * @version 2009-03-06
- */
-public class JSONObject
-{
-
-   /**
-    * JSONObject.NULL is equivalent to the value that JavaScript calls null,
-    * whilst Java's null is equivalent to the value that JavaScript calls
-    * undefined.
-    */
-   private static final class Null
-   {
-
-      /**
-       * There is only intended to be a single instance of the NULL object,
-       * so the clone method returns itself.
-       * @return     NULL.
-       */
-      @Override
-      protected Object clone()
-      {
-         return this;
-      }
-
-      /**
-       * A Null object is equal to the null value and to itself.
-       * @param object    An object to test for nullness.
-       * @return true if the object parameter is the JSONObject.NULL object
-       *  or null.
-       */
-      @Override
-      public boolean equals(final Object object)
-      {
-         return object == null || object == this;
-      }
-
-      @Override
-      public int hashCode()
-      {
-         // TODO
-         return 0;
-      }
-
-      /**
-       * Get the "null" string value.
-       * @return The string "null".
-       */
-      @Override
-      public String toString()
-      {
-         return "null";
-      }
-   }
-
-   /**
-    * The map where the JSONObject's properties are kept.
-    */
-   private final Map map;
-
-   /**
-    * It is sometimes more convenient and less ambiguous to have a
-    * {@code null} object than to use Java's {@code null} value.
-    * <code>JSONObject.NULL.equals(null)</code> returns <code>true</code>.
-    * <code>JSONObject.NULL.toString()</code> returns <code>"null"</code>.
-    */
-   public static final Object NULL = new Null();
-
-   /**
-    * Construct an empty JSONObject.
-    */
-   public JSONObject()
-   {
-      map = new HashMap();
-   }
-
-   /**
-    * Construct a JSONObject from a subset of another JSONObject.
-    * An array of strings is used to identify the keys that should be copied.
-    * Missing keys are ignored.
-    * @param jo A JSONObject.
-    * @param names An array of strings.
-    * @exception JSONException If a value is a non-finite number or if a name is duplicated.
-    */
-   public JSONObject(final JSONObject jo, final String[] names) throws JSONException
-   {
-      this();
-      for (String name : names)
-      {
-         putOnce(name, jo.opt(name));
-      }
-   }
-
-   /**
-    * Construct a JSONObject from a JSONTokener.
-    * @param x A JSONTokener object containing the source string.
-    * @throws JSONException If there is a syntax error in the source string
-    *  or a duplicated key.
-    */
-   public JSONObject(final JSONTokener x) throws JSONException
-   {
-      this();
-      char c;
-      String key;
-
-      if (x.nextClean() != '{')
-      {
-         throw x.syntaxError("A JSONObject text must begin with '{'");
-      }
-      for (;;)
-      {
-         c = x.nextClean();
-         switch (c)
-         {
-            case 0:
-               throw x.syntaxError("A JSONObject text must end with '}'");
-            case '}':
-               return;
-            default:
-               x.back();
-               key = x.nextValue().toString();
-         }
-
-         /*
-          * The key is followed by ':'. We will also tolerate '=' or '=>'.
-          */
-
-         c = x.nextClean();
-         if (c == '=')
-         {
-            if (x.next() != '>')
-            {
-               x.back();
-            }
-         }
-         else if (c != ':')
-         {
-            throw x.syntaxError("Expected a ':' after a key");
-         }
-         putOnce(key, x.nextValue());
-
-         /*
-          * Pairs are separated by ','. We will also tolerate ';'.
-          */
-
-         switch (x.nextClean())
-         {
-            case ';':
-            case ',':
-               if (x.nextClean() == '}')
-               {
-                  return;
-               }
-               x.back();
-               break;
-            case '}':
-               return;
-            default:
-               throw x.syntaxError("Expected a ',' or '}'");
-         }
-      }
-   }
-
-   /**
-    * Construct a JSONObject from a Map.
-    *
-    * @param map A map object that can be used to initialize the contents of
-    *  the JSONObject.
-    */
-   public JSONObject(final Map map)
-   {
-      this.map = map == null ? new HashMap() : map;
-   }
-
-   /**
-    * Construct a JSONObject from a Map.
-    *
-    * Note: Use this constructor when the map contains &lt;key,bean&gt;.
-    *
-    * @param map - A map with Key-Bean data.
-    * @param includeSuperClass - Tell whether to include the super class properties.
-    */
-   public JSONObject(final Map map, final boolean includeSuperClass)
-   {
-      this.map = new HashMap();
-      if (map != null)
-      {
-         Iterator<Map.Entry> i = map.entrySet().iterator();
-         while (i.hasNext())
-         {
-            Map.Entry e = i.next();
-            if (JSONObject.isStandardProperty(e.getValue().getClass()))
-            {
-               this.map.put(e.getKey(), e.getValue());
-            }
-            else
-            {
-               this.map.put(e.getKey(), new JSONObject(e.getValue(), includeSuperClass));
-            }
-         }
-      }
-   }
-
-   /**
-    * Construct a JSONObject from an Object using bean getters.
-    * It reflects on all of the public methods of the object.
-    * For each of the methods with no parameters and a name starting
-    * with <code>"get"</code> or <code>"is"</code> followed by an uppercase letter,
-    * the method is invoked, and a key and the value returned from the getter method
-    * are put into the new JSONObject.
-    *
-    * The key is formed by removing the <code>"get"</code> or <code>"is"</code> prefix.
-    * If the second remaining character is not upper case, then the first
-    * character is converted to lower case.
-    *
-    * For example, if an object has a method named <code>"getName"</code>, and
-    * if the result of calling <code>object.getName()</code> is <code>"Larry Fine"</code>,
-    * then the JSONObject will contain <code>"name": "Larry Fine"</code>.
-    *
-    * @param bean An object that has getter methods that should be used
-    * to make a JSONObject.
-    */
-   public JSONObject(final Object bean)
-   {
-      this();
-      populateInternalMap(bean, false);
-   }
-
-   /**
-    * Construct a JSONObject from an Object using bean getters.
-    * It reflects on all of the public methods of the object.
-    * For each of the methods with no parameters and a name starting
-    * with <code>"get"</code> or <code>"is"</code> followed by an uppercase letter,
-    * the method is invoked, and a key and the value returned from the getter method
-    * are put into the new JSONObject.
-    *
-    * The key is formed by removing the <code>"get"</code> or <code>"is"</code> prefix.
-    * If the second remaining character is not upper case, then the first
-    * character is converted to lower case.
-    *
-    * @param bean An object that has getter methods that should be used
-    * to make a JSONObject.
-    * @param includeSuperClass If true, include the super class properties.
-    */
-   public JSONObject(final Object bean, final boolean includeSuperClass)
-   {
-      this();
-      populateInternalMap(bean, includeSuperClass);
-   }
-
-   private void populateInternalMap(final Object bean, boolean includeSuperClass)
-   {
-      Class klass = bean.getClass();
-
-      /* If klass.getSuperClass is System class then force includeSuperClass to false. */
-
-      if (klass.getClassLoader() == null)
-      {
-         includeSuperClass = false;
-      }
-
-      Method[] methods = includeSuperClass ? klass.getMethods() : klass.getDeclaredMethods();
-      for (Method method : methods)
-      {
-         try
-         {
-            if (Modifier.isPublic(method.getModifiers()))
-            {
-               String name = method.getName();
-               String key = "";
-               if (name.startsWith("get"))
-               {
-                  key = name.substring(3);
-               }
-               else if (name.startsWith("is"))
-               {
-                  key = name.substring(2);
-               }
-               if (key.length() > 0 && Character.isUpperCase(key.charAt(0)) && method.getParameterTypes().length == 0)
-               {
-                  if (key.length() == 1)
-                  {
-                     key = key.toLowerCase();
-                  }
-                  else if (!Character.isUpperCase(key.charAt(1)))
-                  {
-                     key = key.substring(0, 1).toLowerCase() + key.substring(1);
-                  }
-
-                  Object result = method.invoke(bean, (Object[])null);
-                  if (result == null)
-                  {
-                     map.put(key, JSONObject.NULL);
-                  }
-                  else if (result.getClass().isArray())
-                  {
-                     map.put(key, new JSONArray(result, includeSuperClass));
-                  }
-                  else if (result instanceof Collection)
-                  { // List or Set
-                     map.put(key, new JSONArray((Collection)result, includeSuperClass));
-                  }
-                  else if (result instanceof Map)
-                  {
-                     map.put(key, new JSONObject((Map)result, includeSuperClass));
-                  }
-                  else if (JSONObject.isStandardProperty(result.getClass()))
-                  { // Primitives, String and Wrapper
-                     map.put(key, result);
-                  }
-                  else
-                  {
-                     if (result.getClass().getPackage().getName().startsWith("java") || result.getClass()
-                                                                                              .getClassLoader() == null)
-                     {
-                        map.put(key, result.toString());
-                     }
-                     else
-                     { // User defined Objects
-                        map.put(key, new JSONObject(result, includeSuperClass));
-                     }
-                  }
-               }
-            }
-         }
-         catch (IllegalAccessException e)
-         {
-            throw new RuntimeException(e);
-         }
-         catch (JSONException e)
-         {
-            throw new RuntimeException(e);
-         }
-         catch (InvocationTargetException e)
-         {
-            throw new RuntimeException(e);
-         }
-      }
-   }
-
-   static boolean isStandardProperty(final Class<? extends Object> clazz)
-   {
-      return clazz.isPrimitive() || clazz.isAssignableFrom(Byte.class) ||
-             clazz.isAssignableFrom(Short.class) ||
-             clazz.isAssignableFrom(Integer.class) ||
-             clazz.isAssignableFrom(Long.class) ||
-             clazz.isAssignableFrom(Float.class) ||
-             clazz.isAssignableFrom(Double.class) ||
-             clazz.isAssignableFrom(Character.class) ||
-             clazz.isAssignableFrom(String.class) ||
-             clazz.isAssignableFrom(Boolean.class);
-   }
-
-   /**
-    * Construct a JSONObject from an Object, using reflection to find the
-    * public members. The resulting JSONObject's keys will be the strings
-    * from the names array, and the values will be the field values associated
-    * with those keys in the object. If a key is not found or not visible,
-    * then it will not be copied into the new JSONObject.
-    * @param object An object that has fields that should be used to make a
-    * JSONObject.
-    * @param names An array of strings, the names of the fields to be obtained
-    * from the object.
-    */
-   public JSONObject(final Object object, final String[] names)
-   {
-      this();
-      Class c = object.getClass();
-      for (String name : names)
-      {
-         try
-         {
-            putOpt(name, c.getField(name).get(object));
-         }
-         catch (Exception e)
-         {
-            /* forget about it */
-         }
-      }
-   }
-
-   /**
-    * Construct a JSONObject from a source JSON text string.
-    * This is the most commonly used JSONObject constructor.
-    * @param source    A string beginning
-    *  with <code>{</code>&nbsp;<small>(left brace)</small> and ending
-    *  with <code>}</code>&nbsp;<small>(right brace)</small>.
-    * @exception JSONException If there is a syntax error in the source
-    *  string or a duplicated key.
-    */
-   public JSONObject(final String source) throws JSONException
-   {
-      this(new JSONTokener(source));
-   }
-
-   /**
-    * Accumulate values under a key. It is similar to the put method except
-    * that if there is already an object stored under the key then a
-    * JSONArray is stored under the key to hold all of the accumulated values.
-    * If there is already a JSONArray, then the new value is appended to it.
-    * In contrast, the put method replaces the previous value.
-    * @param key   A key string.
-    * @param value An object to be accumulated under the key.
-    * @return this.
-    * @throws JSONException If the value is an invalid number
-    *  or if the key is null.
-    */
-   public JSONObject accumulate(final String key, final Object value) throws JSONException
-   {
-      JSONObject.testValidity(value);
-      Object o = opt(key);
-      if (o == null)
-      {
-         put(key, value instanceof JSONArray ? new JSONArray().put(value) : value);
-      }
-      else if (o instanceof JSONArray)
-      {
-         ((JSONArray)o).put(value);
-      }
-      else
-      {
-         put(key, new JSONArray().put(o).put(value));
-      }
-      return this;
-   }
-
-   /**
-    * Append values to the array under a key. If the key does not exist in the
-    * JSONObject, then the key is put in the JSONObject with its value being a
-    * JSONArray containing the value parameter. If the key was already
-    * associated with a JSONArray, then the value parameter is appended to it.
-    * @param key   A key string.
-    * @param value An object to be accumulated under the key.
-    * @return this.
-    * @throws JSONException If the key is null or if the current value
-    *  associated with the key is not a JSONArray.
-    */
-   public JSONObject append(final String key, final Object value) throws JSONException
-   {
-      JSONObject.testValidity(value);
-      Object o = opt(key);
-      if (o == null)
-      {
-         put(key, new JSONArray().put(value));
-      }
-      else if (o instanceof JSONArray)
-      {
-         put(key, ((JSONArray)o).put(value));
-      }
-      else
-      {
-         throw new JSONException("JSONObject[" + key + "] is not a JSONArray.");
-      }
-      return this;
-   }
-
-   /**
-    * Produce a string from a double. The string "null" will be returned if
-    * the number is not finite.
-    * @param  d A double.
-    * @return A String.
-    */
-   public static String doubleToString(final double d)
-   {
-      if (Double.isInfinite(d) || Double.isNaN(d))
-      {
-         return "null";
-      }
-
-      // Shave off trailing zeros and decimal point, if possible.
-
-      String s = Double.toString(d);
-      if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0)
-      {
-         while (s.endsWith("0"))
-         {
-            s = s.substring(0, s.length() - 1);
-         }
-         if (s.endsWith("."))
-         {
-            s = s.substring(0, s.length() - 1);
-         }
-      }
-      return s;
-   }
-
-   /**
-    * Get the value object associated with a key.
-    *
-    * @param key   A key string.
-    * @return      The object associated with the key.
-    * @throws   JSONException if the key is not found.
-    */
-   public Object get(final String key) throws JSONException
-   {
-      Object o = opt(key);
-      if (o == null)
-      {
-         throw new JSONException("JSONObject[" + JSONObject.quote(key) + "] not found.");
-      }
-      return o;
-   }
-
-   /**
-    * Get the boolean value associated with a key.
-    *
-    * @param key   A key string.
-    * @return      The truth.
-    * @throws   JSONException
-    *  if the value is not a Boolean or the String "true" or "false".
-    */
-   public boolean getBoolean(final String key) throws JSONException
-   {
-      Object o = get(key);
-      if (o.equals(Boolean.FALSE) || o instanceof String && ((String)o).equalsIgnoreCase("false"))
-      {
-         return false;
-      }
-      else if (o.equals(Boolean.TRUE) || o instanceof String && ((String)o).equalsIgnoreCase("true"))
-      {
-         return true;
-      }
-      throw new JSONException("JSONObject[" + JSONObject.quote(key) + "] is not a Boolean.");
-   }
-
-   /**
-    * Get the double value associated with a key.
-    * @param key   A key string.
-    * @return      The numeric value.
-    * @throws JSONException if the key is not found or
-    *  if the value is not a Number object and cannot be converted to a number.
-    */
-   public double getDouble(final String key) throws JSONException
-   {
-      Object o = get(key);
-      try
-      {
-         return o instanceof Number ? ((Number)o).doubleValue() : Double.valueOf((String)o).doubleValue();
-      }
-      catch (Exception e)
-      {
-         throw new JSONException("JSONObject[" + JSONObject.quote(key) + "] is not a number.");
-      }
-   }
-
-   /**
-    * Get the int value associated with a key. If the number value is too
-    * large for an int, it will be clipped.
-    *
-    * @param key   A key string.
-    * @return      The integer value.
-    * @throws   JSONException if the key is not found or if the value cannot
-    *  be converted to an integer.
-    */
-   public int getInt(final String key) throws JSONException
-   {
-      Object o = get(key);
-      return o instanceof Number ? ((Number)o).intValue() : (int)getDouble(key);
-   }
-
-   /**
-    * Get the JSONArray value associated with a key.
-    *
-    * @param key   A key string.
-    * @return      A JSONArray which is the value.
-    * @throws   JSONException if the key is not found or
-    *  if the value is not a JSONArray.
-    */
-   public JSONArray getJSONArray(final String key) throws JSONException
-   {
-      Object o = get(key);
-      if (o instanceof JSONArray)
-      {
-         return (JSONArray)o;
-      }
-      throw new JSONException("JSONObject[" + JSONObject.quote(key) + "] is not a JSONArray.");
-   }
-
-   /**
-    * Get the JSONObject value associated with a key.
-    *
-    * @param key   A key string.
-    * @return      A JSONObject which is the value.
-    * @throws   JSONException if the key is not found or
-    *  if the value is not a JSONObject.
-    */
-   public JSONObject getJSONObject(final String key) throws JSONException
-   {
-      Object o = get(key);
-      if (o instanceof JSONObject)
-      {
-         return (JSONObject)o;
-      }
-      throw new JSONException("JSONObject[" + JSONObject.quote(key) + "] is not a JSONObject.");
-   }
-
-   /**
-    * Get the long value associated with a key. If the number value is too
-    * long for a long, it will be clipped.
-    *
-    * @param key   A key string.
-    * @return      The long value.
-    * @throws   JSONException if the key is not found or if the value cannot
-    *  be converted to a long.
-    */
-   public long getLong(final String key) throws JSONException
-   {
-      Object o = get(key);
-      return o instanceof Number ? ((Number)o).longValue() : (long)getDouble(key);
-   }
-
-   /**
-    * Get an array of field names from a JSONObject.
-    *
-    * @return An array of field names, or null if there are no names.
-    */
-   public static String[] getNames(final JSONObject jo)
-   {
-      int length = jo.length();
-      if (length == 0)
-      {
-         return null;
-      }
-      Iterator i = jo.keys();
-      String[] names = new String[length];
-      int j = 0;
-      while (i.hasNext())
-      {
-         names[j] = (String)i.next();
-         j += 1;
-      }
-      return names;
-   }
-
-   /**
-    * Get an array of field names from an Object.
-    *
-    * @return An array of field names, or null if there are no names.
-    */
-   public static String[] getNames(final Object object)
-   {
-      if (object == null)
-      {
-         return null;
-      }
-      Class klass = object.getClass();
-      Field[] fields = klass.getFields();
-      int length = fields.length;
-      if (length == 0)
-      {
-         return null;
-      }
-      String[] names = new String[length];
-      for (int i = 0; i < length; i += 1)
-      {
-         names[i] = fields[i].getName();
-      }
-      return names;
-   }
-
-   /**
-    * Get the string associated with a key.
-    *
-    * @param key   A key string.
-    * @return      A string which is the value.
-    * @throws   JSONException if the key is not found.
-    */
-   public String getString(final String key) throws JSONException
-   {
-      return get(key).toString();
-   }
-
-   /**
-    * Determine if the JSONObject contains a specific key.
-    * @param key   A key string.
-    * @return      true if the key exists in the JSONObject.
-    */
-   public boolean has(final String key)
-   {
-      return map.containsKey(key);
-   }
-
-   /**
-    * Determine if the value associated with the key is null or if there is
-    *  no value.
-    * @param key   A key string.
-    * @return      true if there is no value associated with the key or if
-    *  the value is the JSONObject.NULL object.
-    */
-   public boolean isNull(final String key)
-   {
-      return JSONObject.NULL.equals(opt(key));
-   }
-
-   /**
-    * Get an enumeration of the keys of the JSONObject.
-    *
-    * @return An iterator of the keys.
-    */
-   public Iterator keys()
-   {
-      return map.keySet().iterator();
-   }
-
-   /**
-    * Get the number of keys stored in the JSONObject.
-    *
-    * @return The number of keys in the JSONObject.
-    */
-   public int length()
-   {
-      return map.size();
-   }
-
-   /**
-    * Produce a JSONArray containing the names of the elements of this
-    * JSONObject.
-    * @return A JSONArray containing the key strings, or null if the JSONObject
-    * is empty.
-    */
-   public JSONArray names()
-   {
-      JSONArray ja = new JSONArray();
-      Iterator keys = keys();
-      while (keys.hasNext())
-      {
-         ja.put(keys.next());
-      }
-      return ja.length() == 0 ? null : ja;
-   }
-
-   /**
-    * Produce a string from a Number.
-    * @param  n A Number
-    * @return A String.
-    * @throws JSONException If n is a non-finite number.
-    */
-   public static String numberToString(final Number n) throws JSONException
-   {
-      if (n == null)
-      {
-         throw new JSONException("Null pointer");
-      }
-      JSONObject.testValidity(n);
-
-      // Shave off trailing zeros and decimal point, if possible.
-
-      String s = n.toString();
-      if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0)
-      {
-         while (s.endsWith("0"))
-         {
-            s = s.substring(0, s.length() - 1);
-         }
-         if (s.endsWith("."))
-         {
-            s = s.substring(0, s.length() - 1);
-         }
-      }
-      return s;
-   }
-
-   /**
-    * Get an optional value associated with a key.
-    * @param key   A key string.
-    * @return      An object which is the value, or null if there is no value.
-    */
-   public Object opt(final String key)
-   {
-      return key == null ? null : map.get(key);
-   }
-
-   /**
-    * Get an optional boolean associated with a key.
-    * It returns false if there is no such key, or if the value is not
-    * Boolean.TRUE or the String "true".
-    *
-    * @param key   A key string.
-    * @return      The truth.
-    */
-   public boolean optBoolean(final String key)
-   {
-      return optBoolean(key, false);
-   }
-
-   /**
-    * Get an optional boolean associated with a key.
-    * It returns the defaultValue if there is no such key, or if it is not
-    * a Boolean or the String "true" or "false" (case insensitive).
-    *
-    * @param key              A key string.
-    * @param defaultValue     The default.
-    * @return      The truth.
-    */
-   public boolean optBoolean(final String key, final boolean defaultValue)
-   {
-      try
-      {
-         return getBoolean(key);
-      }
-      catch (Exception e)
-      {
-         return defaultValue;
-      }
-   }
-
-   /**
-    * Put a key/value pair in the JSONObject, where the value will be a
-    * JSONArray which is produced from a Collection.
-    * @param key   A key string.
-    * @param value A Collection value.
-    * @return      this.
-    * @throws JSONException
-    */
-   public JSONObject put(final String key, final Collection value) throws JSONException
-   {
-      put(key, new JSONArray(value));
-      return this;
-   }
-
-   /**
-    * Get an optional double associated with a key,
-    * or NaN if there is no such key or if its value is not a number.
-    * If the value is a string, an attempt will be made to evaluate it as
-    * a number.
-    *
-    * @param key   A string which is the key.
-    * @return      An object which is the value.
-    */
-   public double optDouble(final String key)
-   {
-      return optDouble(key, Double.NaN);
-   }
-
-   /**
-    * Get an optional double associated with a key, or the
-    * defaultValue if there is no such key or if its value is not a number.
-    * If the value is a string, an attempt will be made to evaluate it as
-    * a number.
-    *
-    * @param key   A key string.
-    * @param defaultValue     The default.
-    * @return      An object which is the value.
-    */
-   public double optDouble(final String key, final double defaultValue)
-   {
-      try
-      {
-         Object o = opt(key);
-         return o instanceof Number ? ((Number)o).doubleValue() : new Double((String)o).doubleValue();
-      }
-      catch (Exception e)
-      {
-         return defaultValue;
-      }
-   }
-
-   /**
-    * Get an optional int value associated with a key,
-    * or zero if there is no such key or if the value is not a number.
-    * If the value is a string, an attempt will be made to evaluate it as
-    * a number.
-    *
-    * @param key   A key string.
-    * @return      An object which is the value.
-    */
-   public int optInt(final String key)
-   {
-      return optInt(key, 0);
-   }
-
-   /**
-    * Get an optional int value associated with a key,
-    * or the default if there is no such key or if the value is not a number.
-    * If the value is a string, an attempt will be made to evaluate it as
-    * a number.
-    *
-    * @param key   A key string.
-    * @param defaultValue     The default.
-    * @return      An object which is the value.
-    */
-   public int optInt(final String key, final int defaultValue)
-   {
-      try
-      {
-         return getInt(key);
-      }
-      catch (Exception e)
-      {
-         return defaultValue;
-      }
-   }
-
-   /**
-    * Get an optional JSONArray associated with a key.
-    * It returns null if there is no such key, or if its value is not a
-    * JSONArray.
-    *
-    * @param key   A key string.
-    * @return      A JSONArray which is the value.
-    */
-   public JSONArray optJSONArray(final String key)
-   {
-      Object o = opt(key);
-      return o instanceof JSONArray ? (JSONArray)o : null;
-   }
-
-   /**
-    * Get an optional JSONObject associated with a key.
-    * It returns null if there is no such key, or if its value is not a
-    * JSONObject.
-    *
-    * @param key   A key string.
-    * @return      A JSONObject which is the value.
-    */
-   public JSONObject optJSONObject(final String key)
-   {
-      Object o = opt(key);
-      return o instanceof JSONObject ? (JSONObject)o : null;
-   }
-
-   /**
-    * Get an optional long value associated with a key,
-    * or zero if there is no such key or if the value is not a number.
-    * If the value is a string, an attempt will be made to evaluate it as
-    * a number.
-    *
-    * @param key   A key string.
-    * @return      An object which is the value.
-    */
-   public long optLong(final String key)
-   {
-      return optLong(key, 0);
-   }
-
-   /**
-    * Get an optional long value associated with a key,
-    * or the default if there is no such key or if the value is not a number.
-    * If the value is a string, an attempt will be made to evaluate it as
-    * a number.
-    *
-    * @param key   A key string.
-    * @param defaultValue     The default.
-    * @return      An object which is the value.
-    */
-   public long optLong(final String key, final long defaultValue)
-   {
-      try
-      {
-         return getLong(key);
-      }
-      catch (Exception e)
-      {
-         return defaultValue;
-      }
-   }
-
-   /**
-    * Get an optional string associated with a key.
-    * It returns an empty string if there is no such key. If the value is not
-    * a string and is not null, then it is converted to a string.
-    *
-    * @param key   A key string.
-    * @return      A string which is the value.
-    */
-   public String optString(final String key)
-   {
-      return optString(key, "");
-   }
-
-   /**
-    * Get an optional string associated with a key.
-    * It returns the defaultValue if there is no such key.
-    *
-    * @param key   A key string.
-    * @param defaultValue     The default.
-    * @return      A string which is the value.
-    */
-   public String optString(final String key, final String defaultValue)
-   {
-      Object o = opt(key);
-      return o != null ? o.toString() : defaultValue;
-   }
-
-   /**
-    * Put a key/boolean pair in the JSONObject.
-    *
-    * @param key   A key string.
-    * @param value A boolean which is the value.
-    * @return this.
-    * @throws JSONException If the key is null.
-    */
-   public JSONObject put(final String key, final boolean value) throws JSONException
-   {
-      put(key, value ? Boolean.TRUE : Boolean.FALSE);
-      return this;
-   }
-
-   /**
-    * Put a key/double pair in the JSONObject.
-    *
-    * @param key   A key string.
-    * @param value A double which is the value.
-    * @return this.
-    * @throws JSONException If the key is null or if the number is invalid.
-    */
-   public JSONObject put(final String key, final double value) throws JSONException
-   {
-      put(key, new Double(value));
-      return this;
-   }
-
-   /**
-    * Put a key/int pair in the JSONObject.
-    *
-    * @param key   A key string.
-    * @param value An int which is the value.
-    * @return this.
-    * @throws JSONException If the key is null.
-    */
-   public JSONObject put(final String key, final int value) throws JSONException
-   {
-      put(key, Integer.valueOf(value));
-      return this;
-   }
-
-   /**
-    * Put a key/long pair in the JSONObject.
-    *
-    * @param key   A key string.
-    * @param value A long which is the value.
-    * @return this.
-    * @throws JSONException If the key is null.
-    */
-   public JSONObject put(final String key, final long value) throws JSONException
-   {
-      put(key, Long.valueOf(value));
-      return this;
-   }
-
-   /**
-    * Put a key/value pair in the JSONObject, where the value will be a
-    * JSONObject which is produced from a Map.
-    * @param key   A key string.
-    * @param value A Map value.
-    * @return      this.
-    * @throws JSONException
-    */
-   public JSONObject put(final String key, final Map value) throws JSONException
-   {
-      put(key, new JSONObject(value));
-      return this;
-   }
-
-   /**
-    * Put a key/value pair in the JSONObject. If the value is null,
-    * then the key will be removed from the JSONObject if it is present.
-    * @param key   A key string.
-    * @param value An object which is the value. It should be of one of these
-    *  types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String,
-    *  or the JSONObject.NULL object.
-    * @return this.
-    * @throws JSONException If the value is non-finite number
-    *  or if the key is null.
-    */
-   public JSONObject put(final String key, final Object value) throws JSONException
-   {
-      if (key == null)
-      {
-         throw new JSONException("Null key.");
-      }
-      if (value != null)
-      {
-         JSONObject.testValidity(value);
-         map.put(key, value);
-      }
-      else
-      {
-         remove(key);
-      }
-      return this;
-   }
-
-   /**
-    * Put a key/value pair in the JSONObject, but only if the key and the
-    * value are both non-null, and only if there is not already a member
-    * with that name.
-    * @param key
-    * @param value
-    * @return his.
-    * @throws JSONException if the key is a duplicate
-    */
-   public JSONObject putOnce(final String key, final Object value) throws JSONException
-   {
-      if (key != null && value != null)
-      {
-         if (opt(key) != null)
-         {
-            throw new JSONException("Duplicate key \"" + key + "\"");
-         }
-         put(key, value);
-      }
-      return this;
-   }
-
-   /**
-    * Put a key/value pair in the JSONObject, but only if the
-    * key and the value are both non-null.
-    * @param key   A key string.
-    * @param value An object which is the value. It should be of one of these
-    *  types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String,
-    *  or the JSONObject.NULL object.
-    * @return this.
-    * @throws JSONException If the value is a non-finite number.
-    */
-   public JSONObject putOpt(final String key, final Object value) throws JSONException
-   {
-      if (key != null && value != null)
-      {
-         put(key, value);
-      }
-      return this;
-   }
-
-   /**
-    * Produce a string in double quotes with backslash sequences in all the
-    * right places. A backslash will be inserted within &lt;/, allowing JSON
-    * text to be delivered in HTML. In JSON text, a string cannot contain a
-    * control character or an unescaped quote or backslash.
-    * @param string A String
-    * @return  A String correctly formatted for insertion in a JSON text.
-    */
-   public static String quote(final String string)
-   {
-      if (string == null || string.length() == 0)
-      {
-         return "\"\"";
-      }
-
-      char b;
-      char c = 0;
-      int i;
-      int len = string.length();
-      StringBuffer sb = new StringBuffer(len + 4);
-      String t;
-
-      sb.append('"');
-      for (i = 0; i < len; i += 1)
-      {
-         b = c;
-         c = string.charAt(i);
-         switch (c)
-         {
-            case '\\':
-            case '"':
-               sb.append('\\');
-               sb.append(c);
-               break;
-            case '/':
-               if (b == '<')
-               {
-                  sb.append('\\');
-               }
-               sb.append(c);
-               break;
-            case '\b':
-               sb.append("\\b");
-               break;
-            case '\t':
-               sb.append("\\t");
-               break;
-            case '\n':
-               sb.append("\\n");
-               break;
-            case '\f':
-               sb.append("\\f");
-               break;
-            case '\r':
-               sb.append("\\r");
-               break;
-            default:
-               if (c < ' ' || c >= '\u0080' && c < '\u00a0' || c >= '\u2000' && c < '\u2100')
-               {
-                  t = "000" + Integer.toHexString(c);
-                  sb.append("\\u" + t.substring(t.length() - 4));
-               }
-               else
-               {
-                  sb.append(c);
-               }
-         }
-      }
-      sb.append('"');
-      return sb.toString();
-   }
-
-   /**
-    * Remove a name and its value, if present.
-    * @param key The name to be removed.
-    * @return The value that was associated with the name,
-    * or null if there was no value.
-    */
-   public Object remove(final String key)
-   {
-      return map.remove(key);
-   }
-
-   /**
-    * Get an enumeration of the keys of the JSONObject.
-    * The keys will be sorted alphabetically.
-    *
-    * @return An iterator of the keys.
-    */
-   public Iterator sortedKeys()
-   {
-      return new TreeSet(map.keySet()).iterator();
-   }
-
-   /**
-    * Try to convert a string into a number, boolean, or null. If the string
-    * can't be converted, return the string.
-    * @param s A String.
-    * @return A simple JSON value.
-    */
-   public static Object stringToValue(final String s)
-   {
-      if (s.equals(""))
-      {
-         return s;
-      }
-      if (s.equalsIgnoreCase("true"))
-      {
-         return Boolean.TRUE;
-      }
-      if (s.equalsIgnoreCase("false"))
-      {
-         return Boolean.FALSE;
-      }
-      if (s.equalsIgnoreCase("null"))
-      {
-         return JSONObject.NULL;
-      }
-
-      /*
-       * If it might be a number, try converting it. We support the 0- and 0x-
-       * conventions. If a number cannot be produced, then the value will just
-       * be a string. Note that the 0-, 0x-, plus, and implied string
-       * conventions are non-standard. A JSON parser is free to accept
-       * non-JSON forms as long as it accepts all correct JSON forms.
-       */
-
-      char b = s.charAt(0);
-      if (b >= '0' && b <= '9' || b == '.' || b == '-' || b == '+')
-      {
-         if (b == '0')
-         {
-            if (s.length() > 2 && (s.charAt(1) == 'x' || s.charAt(1) == 'X'))
-            {
-               try
-               {
-                  return Integer.valueOf(Integer.parseInt(s.substring(2), 16));
-               }
-               catch (Exception e)
-               {
-                  /* Ignore the error */
-               }
-            }
-            else
-            {
-               try
-               {
-                  return Integer.valueOf(Integer.parseInt(s, 8));
-               }
-               catch (Exception e)
-               {
-                  /* Ignore the error */
-               }
-            }
-         }
-         try
-         {
-            if (s.indexOf('.') > -1 || s.indexOf('e') > -1 || s.indexOf('E') > -1)
-            {
-               return Double.valueOf(s);
-            }
-            else
-            {
-               Long myLong = Long.valueOf(s);
-               if (myLong.longValue() == myLong.intValue())
-               {
-                  return Integer.valueOf(myLong.intValue());
-               }
-               else
-               {
-                  return myLong;
-               }
-            }
-         }
-         catch (Exception f)
-         {
-            /* Ignore the error */
-         }
-      }
-      return s;
-   }
-
-   /**
-    * Throw an exception if the object is an NaN or infinite number.
-    * @param o The object to test.
-    * @throws JSONException If o is a non-finite number.
-    */
-   static void testValidity(final Object o) throws JSONException
-   {
-      if (o != null)
-      {
-         if (o instanceof Double)
-         {
-            if (((Double)o).isInfinite() || ((Double)o).isNaN())
-            {
-               throw new JSONException("JSON does not allow non-finite numbers.");
-            }
-         }
-         else if (o instanceof Float)
-         {
-            if (((Float)o).isInfinite() || ((Float)o).isNaN())
-            {
-               throw new JSONException("JSON does not allow non-finite numbers.");
-            }
-         }
-      }
-   }
-
-   /**
-    * Produce a JSONArray containing the values of the members of this
-    * JSONObject.
-    * @param names A JSONArray containing a list of key strings. This
-    * determines the sequence of the values in the result.
-    * @return A JSONArray of values.
-    * @throws JSONException If any of the values are non-finite numbers.
-    */
-   public JSONArray toJSONArray(final JSONArray names) throws JSONException
-   {
-      if (names == null || names.length() == 0)
-      {
-         return null;
-      }
-      JSONArray ja = new JSONArray();
-      for (int i = 0; i < names.length(); i += 1)
-      {
-         ja.put(opt(names.getString(i)));
-      }
-      return ja;
-   }
-
-   /**
-    * Make a JSON text of this JSONObject. For compactness, no whitespace
-    * is added. If this would not result in a syntactically correct JSON text,
-    * then null will be returned instead.
-    * <p>
-    * Warning: This method assumes that the data structure is acyclical.
-    *
-    * @return a printable, displayable, portable, transmittable
-    *  representation of the object, beginning
-    *  with <code>{</code>&nbsp;<small>(left brace)</small> and ending
-    *  with <code>}</code>&nbsp;<small>(right brace)</small>.
-    */
-   @Override
-   public String toString()
-   {
-      try
-      {
-         Iterator keys = keys();
-         StringBuilder sb = new StringBuilder("{");
-
-         while (keys.hasNext())
-         {
-            if (sb.length() > 1)
-            {
-               sb.append(',');
-            }
-            Object o = keys.next();
-            sb.append(JSONObject.quote(o.toString()));
-            sb.append(':');
-            sb.append(JSONObject.valueToString(map.get(o)));
-         }
-         sb.append('}');
-         return sb.toString();
-      }
-      catch (JSONException e)
-      {
-         return null;
-      }
-   }
-
-   /**
-    * Make a prettyprinted JSON text of this JSONObject.
-    * <p>
-    * Warning: This method assumes that the data structure is acyclical.
-    * @param indentFactor The number of spaces to add to each level of
-    *  indentation.
-    * @return a printable, displayable, portable, transmittable
-    *  representation of the object, beginning
-    *  with <code>{</code>&nbsp;<small>(left brace)</small> and ending
-    *  with <code>}</code>&nbsp;<small>(right brace)</small>.
-    * @throws JSONException If the object contains an invalid number.
-    */
-   public String toString(final int indentFactor) throws JSONException
-   {
-      return toString(indentFactor, 0);
-   }
-
-   /**
-    * Make a prettyprinted JSON text of this JSONObject.
-    * <p>
-    * Warning: This method assumes that the data structure is acyclical.
-    * @param indentFactor The number of spaces to add to each level of
-    *  indentation.
-    * @param indent The indentation of the top level.
-    * @return a printable, displayable, transmittable
-    *  representation of the object, beginning
-    *  with <code>{</code>&nbsp;<small>(left brace)</small> and ending
-    *  with <code>}</code>&nbsp;<small>(right brace)</small>.
-    * @throws JSONException If the object contains an invalid number.
-    */
-   String toString(final int indentFactor, final int indent) throws JSONException
-   {
-      int j;
-      int n = length();
-      if (n == 0)
-      {
-         return "{}";
-      }
-      Iterator keys = sortedKeys();
-      StringBuffer sb = new StringBuffer("{");
-      int newindent = indent + indentFactor;
-      Object o;
-      if (n == 1)
-      {
-         o = keys.next();
-         sb.append(JSONObject.quote(o.toString()));
-         sb.append(": ");
-         sb.append(JSONObject.valueToString(map.get(o), indentFactor, indent));
-      }
-      else
-      {
-         while (keys.hasNext())
-         {
-            o = keys.next();
-            if (sb.length() > 1)
-            {
-               sb.append(",\n");
-            }
-            else
-            {
-               sb.append('\n');
-            }
-            for (j = 0; j < newindent; j += 1)
-            {
-               sb.append(' ');
-            }
-            sb.append(JSONObject.quote(o.toString()));
-            sb.append(": ");
-            sb.append(JSONObject.valueToString(map.get(o), indentFactor, newindent));
-         }
-         if (sb.length() > 1)
-         {
-            sb.append('\n');
-            for (j = 0; j < indent; j += 1)
-            {
-               sb.append(' ');
-            }
-         }
-      }
-      sb.append('}');
-      return sb.toString();
-   }
-
-   /**
-    * Make a JSON text of an Object value. If the object has an
-    * value.toJSONString() method, then that method will be used to produce
-    * the JSON text. The method is required to produce a strictly
-    * conforming text. If the object does not contain a toJSONString
-    * method (which is the most common case), then a text will be
-    * produced by other means. If the value is an array or Collection,
-    * then a JSONArray will be made from it and its toJSONString method
-    * will be called. If the value is a MAP, then a JSONObject will be made
-    * from it and its toJSONString method will be called. Otherwise, the
-    * value's toString method will be called, and the result will be quoted.
-    *
-    * <p>
-    * Warning: This method assumes that the data structure is acyclical.
-    * @param value The value to be serialized.
-    * @return a printable, displayable, transmittable
-    *  representation of the object, beginning
-    *  with <code>{</code>&nbsp;<small>(left brace)</small> and ending
-    *  with <code>}</code>&nbsp;<small>(right brace)</small>.
-    * @throws JSONException If the value is or contains an invalid number.
-    */
-   static String valueToString(final Object value) throws JSONException
-   {
-      if (value == null || JSONObject.NULL == value)
-      {
-         return "null";
-      }
-      if (value instanceof JSONString)
-      {
-         String o;
-         try
-         {
-            o = ((JSONString)value).toJSONString();
-         }
-         catch (RuntimeException e)
-         {
-            throw new JSONException(e);
-         }
-         if (o == null)
-            throw new JSONException("Bad value from toJSONString: " + o);
-         return o;
-      }
-      if (value instanceof Number)
-      {
-         return JSONObject.numberToString((Number)value);
-      }
-      if (value instanceof Boolean || value instanceof JSONObject || value instanceof JSONArray)
-      {
-         return value.toString();
-      }
-      if (value instanceof Map)
-      {
-         return new JSONObject((Map)value).toString();
-      }
-      if (value instanceof Collection)
-      {
-         return new JSONArray((Collection)value).toString();
-      }
-      if (value.getClass().isArray())
-      {
-         return new JSONArray(value).toString();
-      }
-      return JSONObject.quote(value.toString());
-   }
-
-   /**
-    * Make a prettyprinted JSON text of an object value.
-    * <p>
-    * Warning: This method assumes that the data structure is acyclical.
-    * @param value The value to be serialized.
-    * @param indentFactor The number of spaces to add to each level of
-    *  indentation.
-    * @param indent The indentation of the top level.
-    * @return a printable, displayable, transmittable
-    *  representation of the object, beginning
-    *  with <code>{</code>&nbsp;<small>(left brace)</small> and ending
-    *  with <code>}</code>&nbsp;<small>(right brace)</small>.
-    * @throws JSONException If the object contains an invalid number.
-    */
-   static String valueToString(final Object value, final int indentFactor, final int indent) throws JSONException
-   {
-      if (value == null || JSONObject.NULL == value)
-      {
-         return "null";
-      }
-      try
-      {
-         if (value instanceof JSONString)
-         {
-            String o = ((JSONString)value).toJSONString();
-            if (o != null)
-               return o;
-         }
-      }
-      catch (RuntimeException e)
-      {
-         /* forget about it */
-      }
-      if (value instanceof Number)
-      {
-         return JSONObject.numberToString((Number)value);
-      }
-      if (value instanceof Boolean)
-      {
-         return value.toString();
-      }
-      if (value instanceof JSONObject)
-      {
-         return ((JSONObject)value).toString(indentFactor, indent);
-      }
-      if (value instanceof JSONArray)
-      {
-         return ((JSONArray)value).toString(indentFactor, indent);
-      }
-      if (value instanceof Map)
-      {
-         return new JSONObject((Map)value).toString(indentFactor, indent);
-      }
-      if (value instanceof Collection)
-      {
-         return new JSONArray((Collection)value).toString(indentFactor, indent);
-      }
-      if (value.getClass().isArray())
-      {
-         return new JSONArray(value).toString(indentFactor, indent);
-      }
-      return JSONObject.quote(value.toString());
-   }
-
-   /**
-    * Write the contents of the JSONObject as JSON text to a writer.
-    * For compactness, no whitespace is added.
-    * <p>
-    * Warning: This method assumes that the data structure is acyclical.
-    *
-    * @return The writer.
-    * @throws JSONException
-    */
-   public Writer write(final Writer writer) throws JSONException
-   {
-      try
-      {
-         boolean b = false;
-         Iterator keys = keys();
-         writer.write('{');
-
-         while (keys.hasNext())
-         {
-            if (b)
-            {
-               writer.write(',');
-            }
-            Object k = keys.next();
-            writer.write(JSONObject.quote(k.toString()));
-            writer.write(':');
-            Object v = map.get(k);
-            if (v instanceof JSONObject)
-            {
-               ((JSONObject)v).write(writer);
-            }
-            else if (v instanceof JSONArray)
-            {
-               ((JSONArray)v).write(writer);
-            }
-            else
-            {
-               writer.write(JSONObject.valueToString(v));
-            }
-            b = true;
-         }
-         writer.write('}');
-         return writer;
-      }
-      catch (IOException e)
-      {
-         throw new JSONException(e);
-      }
-   }
-}
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONString.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONString.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONString.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONString.java	1970-01-01 01:00:00.000000000 +0100
@@ -1,56 +0,0 @@
-/*
- * Copyright 2005-2014 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-/*
-Copyright (c) 2002 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-package org.hornetq.utils.json;
-
-/**
- * The <code>JSONString</code> interface allows a <code>toJSONString()</code>
- * method so that a class can change the behavior of
- * <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>,
- * and <code>JSONWriter.value(</code>Object<code>)</code>. The
- * <code>toJSONString</code> method will be used instead of the default behavior
- * of using the Object's <code>toString()</code> method and quoting the result.
- */
-public interface JSONString
-{
-   /**
-    * The <code>toJSONString</code> method allows a class to produce its own JSON
-    * serialization.
-    *
-    * @return A strictly syntactically correct JSON text.
-    */
-   String toJSONString();
-}
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONTokener.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONTokener.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONTokener.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-core-client/src/main/java/org/hornetq/utils/json/JSONTokener.java	1970-01-01 01:00:00.000000000 +0100
@@ -1,476 +0,0 @@
-/*
- * Copyright 2005-2014 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *    http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.  See the License for the specific language governing
- * permissions and limitations under the License.
- */
-/*
-Copyright (c) 2002 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-package org.hornetq.utils.json;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-
-/**
- * A JSONTokener takes a source string and extracts characters and tokens from
- * it. It is used by the JSONObject and JSONArray constructors to parse
- * JSON source strings.
- * @author JSON.org
- * @version 2008-09-18
- */
-public class JSONTokener
-{
-
-   private int index;
-
-   private final Reader reader;
-
-   private char lastChar;
-
-   private boolean useLastChar;
-
-   /**
-    * Construct a JSONTokener from a string.
-    *
-    * @param reader     A reader.
-    */
-   public JSONTokener(final Reader reader)
-   {
-      this.reader = reader.markSupported() ? reader : new BufferedReader(reader);
-      useLastChar = false;
-      index = 0;
-   }
-
-   /**
-    * Construct a JSONTokener from a string.
-    *
-    * @param s     A source string.
-    */
-   public JSONTokener(final String s)
-   {
-      this(new StringReader(s));
-   }
-
-   /**
-    * Back up one character. This provides a sort of lookahead capability,
-    * so that you can test for a digit or letter before attempting to parse
-    * the next number or identifier.
-    */
-   public void back() throws JSONException
-   {
-      if (useLastChar || index <= 0)
-      {
-         throw new JSONException("Stepping back two steps is not supported");
-      }
-      index -= 1;
-      useLastChar = true;
-   }
-
-   /**
-    * Get the hex value of a character (base16).
-    * @param c A character between '0' and '9' or between 'A' and 'F' or
-    * between 'a' and 'f'.
-    * @return  An int between 0 and 15, or -1 if c was not a hex digit.
-    */
-   public static int dehexchar(final char c)
-   {
-      if (c >= '0' && c <= '9')
-      {
-         return c - '0';
-      }
-      if (c >= 'A' && c <= 'F')
-      {
-         return c - ('A' - 10);
-      }
-      if (c >= 'a' && c <= 'f')
-      {
-         return c - ('a' - 10);
-      }
-      return -1;
-   }
-
-   /**
-    * Determine if the source string still contains characters that next()
-    * can consume.
-    * @return true if not yet at the end of the source.
-    */
-   public boolean more() throws JSONException
-   {
-      char nextChar = next();
-      if (nextChar == 0)
-      {
-         return false;
-      }
-      back();
-      return true;
-   }
-
-   /**
-    * Get the next character in the source string.
-    *
-    * @return The next character, or 0 if past the end of the source string.
-    */
-   public char next() throws JSONException
-   {
-      if (useLastChar)
-      {
-         useLastChar = false;
-         if (lastChar != 0)
-         {
-            index += 1;
-         }
-         return lastChar;
-      }
-      int c;
-      try
-      {
-         c = reader.read();
-      }
-      catch (IOException exc)
-      {
-         throw new JSONException(exc);
-      }
-
-      if (c <= 0)
-      { // End of stream
-         lastChar = 0;
-         return 0;
-      }
-      index += 1;
-      lastChar = (char)c;
-      return lastChar;
-   }
-
-   /**
-    * Consume the next character, and check that it matches a specified
-    * character.
-    * @param c The character to match.
-    * @return The character.
-    * @throws JSONException if the character does not match.
-    */
-   public char next(final char c) throws JSONException
-   {
-      char n = next();
-      if (n != c)
-      {
-         throw syntaxError("Expected '" + c + "' and instead saw '" + n + "'");
-      }
-      return n;
-   }
-
-   /**
-    * Get the next n characters.
-    *
-    * @param n     The number of characters to take.
-    * @return      A string of n characters.
-    * @throws JSONException
-    *   Substring bounds error if there are not
-    *   n characters remaining in the source string.
-    */
-   public String next(final int n) throws JSONException
-   {
-      if (n == 0)
-      {
-         return "";
-      }
-
-      char[] buffer = new char[n];
-      int pos = 0;
-
-      if (useLastChar)
-      {
-         useLastChar = false;
-         buffer[0] = lastChar;
-         pos = 1;
-      }
-
-      try
-      {
-         int len;
-         while (pos < n && (len = reader.read(buffer, pos, n - pos)) != -1)
-         {
-            pos += len;
-         }
-      }
-      catch (IOException exc)
-      {
-         throw new JSONException(exc);
-      }
-      index += pos;
-
-      if (pos < n)
-      {
-         throw syntaxError("Substring bounds error");
-      }
-
-      lastChar = buffer[n - 1];
-      return new String(buffer);
-   }
-
-   /**
-    * Get the next char in the string, skipping whitespace.
-    * @throws JSONException
-    * @return  A character, or 0 if there are no more characters.
-    */
-   public char nextClean() throws JSONException
-   {
-      for (;;)
-      {
-         char c = next();
-         if (c == 0 || c > ' ')
-         {
-            return c;
-         }
-      }
-   }
-
-   /**
-    * Return the characters up to the next close quote character.
-    * Backslash processing is done. The formal JSON format does not
-    * allow strings in single quotes, but an implementation is allowed to
-    * accept them.
-    * @param quote The quoting character, either
-    *      <code>"</code>&nbsp;<small>(double quote)</small> or
-    *      <code>'</code>&nbsp;<small>(single quote)</small>.
-    * @return      A String.
-    * @throws JSONException Unterminated string.
-    */
-   public String nextString(final char quote) throws JSONException
-   {
-      char c;
-      StringBuffer sb = new StringBuffer();
-      for (;;)
-      {
-         c = next();
-         switch (c)
-         {
-            case 0:
-            case '\n':
-            case '\r':
-               throw syntaxError("Unterminated string");
-            case '\\':
-               c = next();
-               switch (c)
-               {
-                  case 'b':
-                     sb.append('\b');
-                     break;
-                  case 't':
-                     sb.append('\t');
-                     break;
-                  case 'n':
-                     sb.append('\n');
-                     break;
-                  case 'f':
-                     sb.append('\f');
-                     break;
-                  case 'r':
-                     sb.append('\r');
-                     break;
-                  case 'u':
-                     sb.append((char)Integer.parseInt(next(4), 16));
-                     break;
-                  case 'x':
-                     sb.append((char)Integer.parseInt(next(2), 16));
-                     break;
-                  default:
-                     sb.append(c);
-               }
-               break;
-            default:
-               if (c == quote)
-               {
-                  return sb.toString();
-               }
-               sb.append(c);
-         }
-      }
-   }
-
-   /**
-    * Get the text up but not including the specified character or the
-    * end of line, whichever comes first.
-    * @param  d A delimiter character.
-    * @return   A string.
-    */
-   public String nextTo(final char d) throws JSONException
-   {
-      StringBuffer sb = new StringBuffer();
-      for (;;)
-      {
-         char c = next();
-         if (c == d || c == 0 || c == '\n' || c == '\r')
-         {
-            if (c != 0)
-            {
-               back();
-            }
-            return sb.toString().trim();
-         }
-         sb.append(c);
-      }
-   }
-
-   /**
-    * Get the text up but not including one of the specified delimiter
-    * characters or the end of line, whichever comes first.
-    * @param delimiters A set of delimiter characters.
-    * @return A string, trimmed.
-    */
-   public String nextTo(final String delimiters) throws JSONException
-   {
-      char c;
-      StringBuffer sb = new StringBuffer();
-      for (;;)
-      {
-         c = next();
-         if (delimiters.indexOf(c) >= 0 || c == 0 || c == '\n' || c == '\r')
-         {
-            if (c != 0)
-            {
-               back();
-            }
-            return sb.toString().trim();
-         }
-         sb.append(c);
-      }
-   }
-
-   /**
-    * Get the next value. The value can be a Boolean, Double, Integer,
-    * JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
-    * @throws JSONException If syntax error.
-    *
-    * @return An object.
-    */
-   public Object nextValue() throws JSONException
-   {
-      char c = nextClean();
-      String s;
-
-      switch (c)
-      {
-         case '"':
-         case '\'':
-            return nextString(c);
-         case '{':
-            back();
-            return new JSONObject(this);
-         case '[':
-         case '(':
-            back();
-            return new JSONArray(this);
-      }
-
-      /*
-       * Handle unquoted text. This could be the values true, false, or
-       * null, or it can be a number. An implementation (such as this one)
-       * is allowed to also accept non-standard forms.
-       *
-       * Accumulate characters until we reach the end of the text or a
-       * formatting character.
-       */
-
-      StringBuffer sb = new StringBuffer();
-      while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0)
-      {
-         sb.append(c);
-         c = next();
-      }
-      back();
-
-      s = sb.toString().trim();
-      if (s.equals(""))
-      {
-         throw syntaxError("Missing value");
-      }
-      return JSONObject.stringToValue(s);
-   }
-
-   /**
-    * Skip characters until the next character is the requested character.
-    * If the requested character is not found, no characters are skipped.
-    * @param to A character to skip to.
-    * @return The requested character, or zero if the requested character
-    * is not found.
-    */
-   public char skipTo(final char to) throws JSONException
-   {
-      char c;
-      try
-      {
-         int startIndex = index;
-         reader.mark(Integer.MAX_VALUE);
-         do
-         {
-            c = next();
-            if (c == 0)
-            {
-               reader.reset();
-               index = startIndex;
-               return c;
-            }
-         }
-         while (c != to);
-      }
-      catch (IOException exc)
-      {
-         throw new JSONException(exc);
-      }
-
-      back();
-      return c;
-   }
-
-   /**
-    * Make a JSONException to signal a syntax error.
-    *
-    * @param message The error message.
-    * @return  A JSONException object, suitable for throwing
-    */
-   public JSONException syntaxError(final String message)
-   {
-      return new JSONException(message + toString());
-   }
-
-   /**
-    * Make a printable string of this JSONTokener.
-    *
-    * @return " at character [this.index]"
-    */
-   @Override
-   public String toString()
-   {
-      return " at character " + index;
-   }
-}
\ Manca newline alla fine del file
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/JMSConnectionInfo.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/JMSConnectionInfo.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/JMSConnectionInfo.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/JMSConnectionInfo.java	2016-07-18 13:32:39.244998230 +0200
@@ -12,8 +12,10 @@
  */
 package org.hornetq.api.jms.management;
 
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
+import org.hornetq.api.core.JsonUtil;
+
+import javax.json.JsonArray;
+import javax.json.JsonObject;
 
 /**
  * A JMSConnectionInfo
@@ -40,19 +42,17 @@
 
    public static JMSConnectionInfo[] from(final String jsonString) throws Exception
    {
-      JSONArray array = new JSONArray(jsonString);
-      JMSConnectionInfo[] infos = new JMSConnectionInfo[array.length()];
-      for (int i = 0; i < array.length(); i++)
-      {
-         JSONObject obj = array.getJSONObject(i);
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      JMSConnectionInfo[] infos = new JMSConnectionInfo[array.size()];
+      for (int i = 0; i < array.size(); i++) {
+         JsonObject obj = array.getJsonObject(i);
          String cid = obj.isNull("clientID") ? null : obj.getString("clientID");
          String uname = obj.isNull("principal") ? null : obj.getString("principal");
 
          JMSConnectionInfo info = new JMSConnectionInfo(obj.getString("connectionID"),
-                                                        obj.getString("clientAddress"),
-                                                        obj.getLong("creationTime"),
-                                                        cid,
-                                                        uname);
+               obj.getString("clientAddress"),
+               obj.getJsonNumber("creationTime").longValue(),
+               cid, uname);
          infos[i] = info;
       }
       return infos;
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/JMSConsumerInfo.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/JMSConsumerInfo.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/JMSConsumerInfo.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/JMSConsumerInfo.java	2016-07-18 10:39:36.287538583 +0200
@@ -12,8 +12,10 @@
  */
 package org.hornetq.api.jms.management;
 
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
+import org.hornetq.api.core.JsonUtil;
+
+import javax.json.JsonArray;
+import javax.json.JsonObject;
 
 /**
  * Helper class to create Java Objects from the
@@ -47,19 +49,18 @@
     */
    public static JMSConsumerInfo[] from(final String jsonString) throws Exception
    {
-      JSONArray array = new JSONArray(jsonString);
-      JMSConsumerInfo[] infos = new JMSConsumerInfo[array.length()];
-      for (int i = 0; i < array.length(); i++)
-      {
-         JSONObject sub = array.getJSONObject(i);
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      JMSConsumerInfo[] infos = new JMSConsumerInfo[array.size()];
+      for (int i = 0; i < array.size(); i++) {
+         JsonObject sub = array.getJsonObject(i);
          JMSConsumerInfo info = new JMSConsumerInfo(sub.getString("consumerID"),
-                                                    sub.getString("connectionID"),
-                                                    sub.getString("destinationName"),
-                                                    sub.getString("destinationType"),
-                                                    sub.getBoolean("browseOnly"),
-                                                    sub.getLong("creationTime"),
-                                                    sub.getBoolean("durable"),
-                                                    sub.optString("filter", null));
+               sub.getString("connectionID"),
+               sub.getString("destinationName"),
+               sub.getString("destinationType"),
+               sub.getBoolean("browseOnly"),
+               sub.getJsonNumber("creationTime").longValue(),
+               sub.getBoolean("durable"),
+               sub.getString("filter", null));
          infos[i] = info;
       }
 
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/JMSSessionInfo.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/JMSSessionInfo.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/JMSSessionInfo.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/JMSSessionInfo.java	2016-07-18 10:45:03.905973846 +0200
@@ -12,9 +12,10 @@
  */
 package org.hornetq.api.jms.management;
 
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONException;
-import org.hornetq.utils.json.JSONObject;
+import org.hornetq.api.core.JsonUtil;
+
+import javax.json.JsonArray;
+import javax.json.JsonObject;
 
 /**
  * A JMSSessionInfo
@@ -35,16 +36,14 @@
       this.creationTime = creationTime;
    }
 
-   public static JMSSessionInfo[] from(final String jsonString) throws JSONException
-   {
-      JSONArray array = new JSONArray(jsonString);
-      JMSSessionInfo[] infos = new JMSSessionInfo[array.length()];
-      for (int i = 0; i < array.length(); i++)
-      {
-         JSONObject obj = array.getJSONObject(i);
+   public static JMSSessionInfo[] from(final String jsonString) {
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      JMSSessionInfo[] infos = new JMSSessionInfo[array.size()];
+      for (int i = 0; i < array.size(); i++) {
+         JsonObject obj = array.getJsonObject(i);
 
          JMSSessionInfo info = new JMSSessionInfo(obj.getString("sessionID"),
-                                                        obj.getLong("creationTime"));
+               obj.getJsonNumber("creationTime").longValue());
          infos[i] = info;
       }
       return infos;
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/SubscriptionInfo.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/SubscriptionInfo.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/SubscriptionInfo.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-client/src/main/java/org/hornetq/api/jms/management/SubscriptionInfo.java	2016-07-18 10:46:34.479678685 +0200
@@ -12,8 +12,10 @@
  */
 package org.hornetq.api.jms.management;
 
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
+import org.hornetq.api.core.JsonUtil;
+
+import javax.json.JsonArray;
+import javax.json.JsonObject;
 
 /**
  * Helper class to create Java Objects from the
@@ -45,18 +47,17 @@
     */
    public static SubscriptionInfo[] from(final String jsonString) throws Exception
    {
-      JSONArray array = new JSONArray(jsonString);
-      SubscriptionInfo[] infos = new SubscriptionInfo[array.length()];
-      for (int i = 0; i < array.length(); i++)
-      {
-         JSONObject sub = array.getJSONObject(i);
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      SubscriptionInfo[] infos = new SubscriptionInfo[array.size()];
+      for (int i = 0; i < array.size(); i++) {
+         JsonObject sub = array.getJsonObject(i);
          SubscriptionInfo info = new SubscriptionInfo(sub.getString("queueName"),
-                                                      sub.optString("clientID", null),
-                                                      sub.optString("name", null),
-                                                      sub.getBoolean("durable"),
-                                                      sub.optString("selector", null),
-                                                      sub.getInt("messageCount"),
-                                                      sub.getInt("deliveringCount"));
+               sub.getString("clientID", null),
+               sub.getString("name", null),
+               sub.getBoolean("durable"),
+               sub.getString("selector", null),
+               sub.getInt("messageCount"),
+               sub.getInt("deliveringCount"));
          infos[i] = info;
       }
 
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-jms-server/pom.xml hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-server/pom.xml
--- hornetq-HornetQ_2_4_7_Final/hornetq-jms-server/pom.xml	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-server/pom.xml	2016-07-18 10:47:20.340503886 +0200
@@ -45,6 +45,11 @@
          <artifactId>jboss-transaction-api_1.1_spec</artifactId>
       </dependency>
       <dependency>
+         <groupId>org.apache.geronimo.specs</groupId>
+         <artifactId>geronimo-json_1.0_spec</artifactId>
+         <version>1.0-alpha-1</version>
+      </dependency>
+      <dependency>
          <groupId>org.jboss.jbossts.jts</groupId>
          <artifactId>jbossjts-jacorb</artifactId>
          <optional>true</optional>
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-jms-server/src/main/java/org/hornetq/jms/management/impl/JMSQueueControlImpl.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-server/src/main/java/org/hornetq/jms/management/impl/JMSQueueControlImpl.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-jms-server/src/main/java/org/hornetq/jms/management/impl/JMSQueueControlImpl.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-server/src/main/java/org/hornetq/jms/management/impl/JMSQueueControlImpl.java	2016-07-18 10:49:59.610951006 +0200
@@ -12,6 +12,8 @@
  */
 package org.hornetq.jms.management.impl;
 
+import javax.json.Json;
+import javax.json.JsonArrayBuilder;
 import javax.management.MBeanInfo;
 import javax.management.StandardMBean;
 import java.util.HashMap;
@@ -19,6 +21,7 @@
 
 import org.hornetq.api.core.FilterConstants;
 import org.hornetq.api.core.HornetQException;
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.api.core.management.MessageCounterInfo;
 import org.hornetq.api.core.management.Operation;
 import org.hornetq.api.core.management.QueueControl;
@@ -30,8 +33,6 @@
 import org.hornetq.jms.client.HornetQMessage;
 import org.hornetq.jms.client.SelectorTranslator;
 import org.hornetq.jms.server.JMSServerManager;
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
 
 /**
  * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
@@ -64,10 +65,10 @@
 
    static String toJSON(final Map<String, Object>[] messages)
    {
-      JSONArray array = new JSONArray();
+      JsonArrayBuilder array = Json.createArrayBuilder();
       for (Map<String, Object> message : messages)
       {
-         array.put(new JSONObject(message));
+         array.add(JsonUtil.toJsonObject(message));
       }
       return array.toString();
    }
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-jms-server/src/main/java/org/hornetq/jms/management/impl/JMSServerControlImpl.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-server/src/main/java/org/hornetq/jms/management/impl/JMSServerControlImpl.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-jms-server/src/main/java/org/hornetq/jms/management/impl/JMSServerControlImpl.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-server/src/main/java/org/hornetq/jms/management/impl/JMSServerControlImpl.java	2016-07-18 14:06:29.659716535 +0200
@@ -13,6 +13,11 @@
 package org.hornetq.jms.management.impl;
 
 import javax.jms.JMSRuntimeException;
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
 import javax.management.ListenerNotFoundException;
 import javax.management.MBeanNotificationInfo;
 import javax.management.MBeanOperationInfo;
@@ -23,6 +28,7 @@
 import javax.management.NotificationListener;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -50,8 +56,6 @@
 import org.hornetq.jms.server.management.JMSNotificationType;
 import org.hornetq.spi.core.protocol.RemotingConnection;
 import org.hornetq.utils.TypedProperties;
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
 
 /**
  * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
@@ -730,7 +734,7 @@
 
       try
       {
-         JSONArray array = new JSONArray();
+         JsonArrayBuilder array = Json.createArrayBuilder();
 
          Set<RemotingConnection> connections = server.getHornetQServer().getRemotingService().getConnections();
 
@@ -751,13 +755,14 @@
             ServerSession session = jmsSessions.get(connection.getID());
             if (session != null)
             {
-               JSONObject obj = new JSONObject();
-               obj.put("connectionID", connection.getID().toString());
-               obj.put("clientAddress", connection.getRemoteAddress());
-               obj.put("creationTime", connection.getCreationTime());
-               obj.put("clientID", session.getMetaData("jms-client-id"));
-               obj.put("principal", session.getUsername());
-               array.put(obj);
+               JsonObject obj = Json.createObjectBuilder()
+                  .add("connectionID", connection.getID().toString())
+                  .add("clientAddress", connection.getRemoteAddress())
+                  .add("creationTime", connection.getCreationTime())
+                  .add("clientID", session.getMetaData("jms-client-id"))
+                  .add("principal", session.getUsername())
+                  .build();
+               array.add(obj);
             }
          }
          return array.toString();
@@ -776,7 +781,7 @@
 
       try
       {
-         JSONArray array = new JSONArray();
+         JsonArrayBuilder array = Json.createArrayBuilder();
 
          Set<RemotingConnection> connections = server.getHornetQServer().getRemotingService().getConnections();
          for (RemotingConnection connection : connections)
@@ -784,21 +789,11 @@
             if (connectionID.equals(connection.getID().toString()))
             {
                List<ServerSession> sessions = server.getHornetQServer().getSessions(connectionID);
-               for (ServerSession session : sessions)
-               {
-                  Set<ServerConsumer> consumers = session.getServerConsumers();
-                  for (ServerConsumer consumer : consumers)
-                  {
-                     JSONObject obj = toJSONObject(consumer);
-                     if (obj != null)
-                     {
-                        array.put(obj);
-                     }
-                  }
-               }
+               JsonArray jsonSessions = toJsonArray(sessions);
+               array.add(jsonSessions);
             }
          }
-         return array.toString();
+         return array.build().toString();
       }
       finally
       {
@@ -814,22 +809,8 @@
 
       try
       {
-         JSONArray array = new JSONArray();
-
-         Set<ServerSession> sessions = server.getHornetQServer().getSessions();
-         for (ServerSession session : sessions)
-         {
-            Set<ServerConsumer> consumers = session.getServerConsumers();
-            for (ServerConsumer consumer : consumers)
-            {
-               JSONObject obj = toJSONObject(consumer);
-               if (obj != null)
-               {
-                  array.put(obj);
-               }
-            }
-         }
-         return array.toString();
+         JsonArray jsonArray = toJsonArray(server.getHornetQServer().getSessions());
+         return jsonArray.toString();
       }
       finally
       {
@@ -966,16 +947,16 @@
 
       clearIO();
 
-      JSONArray array = new JSONArray();
+      JsonArrayBuilder array = Json.createArrayBuilder();
       try
       {
          List<ServerSession> sessions = server.getHornetQServer().getSessions(connectionID);
          for (ServerSession sess : sessions)
          {
-            JSONObject obj = new JSONObject();
-            obj.put("sessionID", sess.getName());
-            obj.put("creationTime", sess.getCreationTime());
-            array.put(obj);
+            JsonObjectBuilder obj = Json.createObjectBuilder()
+                  .add("sessionID", sess.getName())
+                  .add("creationTime", sess.getCreationTime());
+            array.add(obj);
          }
       }
       finally
@@ -990,50 +971,49 @@
       return server.getHornetQServer().destroyConnectionWithSessionMetadata("jms-client-id", clientID);
    }
 
-   private JSONObject toJSONObject(ServerConsumer consumer) throws Exception
-   {
-      JSONObject obj = new JSONObject();
-      obj.put("consumerID", consumer.getID());
-      obj.put("connectionID", consumer.getConnectionID());
-      obj.put("sessionID", consumer.getSessionID());
-      obj.put("queueName", consumer.getQueue().getName().toString());
-      obj.put("browseOnly", consumer.isBrowseOnly());
-      obj.put("creationTime", consumer.getCreationTime());
-      // JMS consumer with message filter use the queue's filter
-      Filter queueFilter = consumer.getQueue().getFilter();
-      if (queueFilter != null)
-      {
-         obj.put("filter", queueFilter.getFilterString().toString());
-      }
+   private JsonObject toJSONObject(ServerConsumer consumer) {
       String[] destinationInfo = determineJMSDestination(consumer.getQueue().getAddress().toString());
       if (destinationInfo == null)
       {
          return null;
       }
-      obj.put("destinationName", destinationInfo[0]);
-      obj.put("destinationType", destinationInfo[1]);
+      JsonObjectBuilder obj = Json.createObjectBuilder()
+         .add("consumerID", consumer.getID())
+         .add("connectionID", consumer.getConnectionID().toString())
+         .add("sessionID", consumer.getSessionID())
+         .add("queueName", consumer.getQueue().getName().toString())
+         .add("browseOnly", consumer.isBrowseOnly())
+         .add("creationTime", consumer.getCreationTime())
+         .add("destinationName", destinationInfo[0])
+         .add("destinationType", destinationInfo[1]);
+      Filter queueFilter = consumer.getQueue().getFilter();
+      if (queueFilter != null) {
+         obj.add("filter", queueFilter.getFilterString().toString());
+      }
+
+
       if (destinationInfo[1].equals("topic"))
       {
          try
          {
             HornetQDestination.decomposeQueueNameForDurableSubscription(consumer.getQueue().getName().toString());
-            obj.put("durable", true);
+            obj.add("durable", true);
          }
          catch (IllegalArgumentException e)
          {
-            obj.put("durable", false);
+            obj.add("durable", false);
          }
          catch (JMSRuntimeException e)
          {
-            obj.put("durable", false);
+            obj.add("durable", false);
          }
       }
       else
       {
-         obj.put("durable", false);
+         obj.add("durable", false);
       }
 
-      return obj;
+      return obj.build();
    }
 
    @Override
@@ -1047,4 +1027,19 @@
             notifSeq.incrementAndGet(), prop.getSimpleStringProperty(JMSNotificationType.MESSAGE).toString()));
    }
 
+   private JsonArray toJsonArray(Collection<ServerSession> sessions) {
+      JsonArrayBuilder array = Json.createArrayBuilder();
+
+      for (ServerSession session : sessions) {
+         Set<ServerConsumer> consumers = session.getServerConsumers();
+         for (ServerConsumer consumer : consumers) {
+            JsonObject obj = toJSONObject(consumer);
+            if (obj != null) {
+               array.add(obj);
+            }
+         }
+      }
+      return array.build();
+   }
+
 }
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-jms-server/src/main/java/org/hornetq/jms/management/impl/JMSTopicControlImpl.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-server/src/main/java/org/hornetq/jms/management/impl/JMSTopicControlImpl.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-jms-server/src/main/java/org/hornetq/jms/management/impl/JMSTopicControlImpl.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-server/src/main/java/org/hornetq/jms/management/impl/JMSTopicControlImpl.java	2016-07-18 11:01:54.308539109 +0200
@@ -17,6 +17,9 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.json.Json;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
 import javax.management.MBeanInfo;
 import javax.management.StandardMBean;
 
@@ -33,8 +36,6 @@
 import org.hornetq.jms.client.HornetQMessage;
 import org.hornetq.jms.client.SelectorTranslator;
 import org.hornetq.jms.server.JMSServerManager;
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
 
 /**
  * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
@@ -308,7 +309,7 @@
       try
       {
          List<QueueControl> queues = getQueues(durability);
-         JSONArray array = new JSONArray();
+         JsonArrayBuilder array = Json.createArrayBuilder();
 
          for (QueueControl queue : queues)
          {
@@ -333,17 +334,18 @@
 
             String filter = queue.getFilter() != null ? queue.getFilter() : null;
 
-            JSONObject info = new JSONObject();
+            JsonObject info = Json.createObjectBuilder()
+               .add("queueName", queue.getName())
+               .add("clientID", clientID)
+               .add("selector", filter)
+               .add("name", subName)
+               .add("durable", queue.isDurable())
+               .add("messageCount", queue.getMessageCount())
+               .add("deliveringCount", queue.getDeliveringCount())
+               .add("consumers", queue.listConsumersAsJSON())
+               .build();
 
-            info.put("queueName", queue.getName());
-            info.put("clientID", clientID);
-            info.put("selector", filter);
-            info.put("name", subName);
-            info.put("durable", queue.isDurable());
-            info.put("messageCount", queue.getMessageCount());
-            info.put("deliveringCount", queue.getDeliveringCount());
-            info.put("consumers", new JSONArray(queue.listConsumersAsJSON()) );
-            array.put(info);
+            array.add(info);
          }
 
          return array.toString();
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-jms-server/src/main/java/org/hornetq/jms/server/impl/JMSServerManagerImpl.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-server/src/main/java/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-jms-server/src/main/java/org/hornetq/jms/server/impl/JMSServerManagerImpl.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-jms-server/src/main/java/org/hornetq/jms/server/impl/JMSServerManagerImpl.java	2016-07-18 13:47:15.347451020 +0200
@@ -12,6 +12,10 @@
  */
 package org.hornetq.jms.server.impl;
 
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
@@ -85,8 +89,6 @@
 import org.hornetq.spi.core.naming.BindingRegistry;
 import org.hornetq.utils.TimeAndCounterIDGenerator;
 import org.hornetq.utils.TypedProperties;
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
 
 /**
  * A Deployer used to create and add to JNDI queues, topics and connection
@@ -1588,7 +1590,7 @@
          }
       });
 
-      JSONArray txDetailListJson = new JSONArray();
+      JsonArrayBuilder txDetailListJson = Json.createArrayBuilder();
       for (Map.Entry<Xid, Long> entry : xidsSortedByCreationTime)
       {
          Xid xid = entry.getKey();
@@ -1598,7 +1600,7 @@
             continue;
          }
          TransactionDetail detail = new JMSTransactionDetail(xid, tx, entry.getValue());
-         txDetailListJson.put(detail.toJSON());
+         txDetailListJson.add(detail.toJSON());
       }
       return txDetailListJson.toString();
    }
@@ -1634,7 +1636,7 @@
             continue;
          }
          TransactionDetail detail = new JMSTransactionDetail(xid, tx, entry.getValue());
-         JSONObject txJson = detail.toJSON();
+         JsonObject txJson = detail.toJSON();
 
          html.append("<table border=\"1\">");
          html.append("<tr><th>creation_time</th>");
@@ -1652,17 +1654,13 @@
          html.append("<tr><td colspan=\"6\">");
          html.append("<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">");
 
-         JSONArray msgs = txJson.getJSONArray(TransactionDetail.KEY_TX_RELATED_MESSAGES);
-         for (int i = 0; i < msgs.length(); i++)
-         {
-            JSONObject msgJson = msgs.getJSONObject(i);
-            JSONObject props = msgJson.getJSONObject(TransactionDetail.KEY_MSG_PROPERTIES);
+         JsonArray msgs = txJson.getJsonArray(TransactionDetail.KEY_TX_RELATED_MESSAGES);
+         for (int i = 0; i < msgs.size(); i++) {
+            JsonObject msgJson = msgs.getJsonObject(i);
+            JsonObject props = msgJson.getJsonObject(TransactionDetail.KEY_MSG_PROPERTIES);
             StringBuilder propstr = new StringBuilder();
-            @SuppressWarnings("unchecked")
-            Iterator<String> propkeys = props.keys();
-            while (propkeys.hasNext())
-            {
-               String key = propkeys.next();
+
+            for (String key : props.keySet()) {
                propstr.append(key);
                propstr.append("=");
                propstr.append(props.get(key));
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/api/core/management/MessageCounterInfo.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/api/core/management/MessageCounterInfo.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/api/core/management/MessageCounterInfo.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/api/core/management/MessageCounterInfo.java	2016-07-18 11:11:07.976655043 +0200
@@ -15,8 +15,11 @@
 import java.text.DateFormat;
 import java.util.Date;
 
+import javax.json.Json;
+import javax.json.JsonObject;
+
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.core.messagecounter.MessageCounter;
-import org.hornetq.utils.json.JSONObject;
 
 /**
  * Helper class to create Java Objects from the
@@ -54,27 +57,35 @@
    {
       DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
 
-      JSONObject json = new JSONObject(counter);
       String lastAddTimestamp = dateFormat.format(new Date(counter.getLastAddedMessageTime()));
-      json.put("lastAddTimestamp", lastAddTimestamp);
       String updateTimestamp = dateFormat.format(new Date(counter.getLastUpdate()));
-      json.put("updateTimestamp", updateTimestamp);
 
-      return json.toString();
+      return Json.createObjectBuilder()
+         .add("destinationName", counter.getDestinationName())
+         .add("destinationSubscription", counter.getDestinationSubscription())
+         .add("destinationDurable", counter.isDestinationDurable())
+         .add("count", counter.getCount())
+         .add("countDelta", counter.getCountDelta())
+         .add("messageCount", counter.getMessageCount())
+         .add("messageCountDelta", counter.getMessageCountDelta())
+         .add("lastAddTimestamp", lastAddTimestamp)
+         .add("updateTimestamp", updateTimestamp)
+         .build()
+         .toString();
    }
 
    /**
-    * Returns an array of RoleInfo corresponding to the JSON serialization returned
+    * Returns a MessageCounterInfo corresponding to the JSON serialization returned
     * by {@link QueueControl#listMessageCounter()}.
     */
    public static MessageCounterInfo fromJSON(final String jsonString) throws Exception
    {
-      JSONObject data = new JSONObject(jsonString);
+      JsonObject data = JsonUtil.readJsonObject(jsonString);
       String name = data.getString("destinationName");
       String subscription = data.getString("destinationSubscription");
       boolean durable = data.getBoolean("destinationDurable");
-      long count = data.getLong("count");
-      long countDelta = data.getLong("countDelta");
+      long count = data.getJsonNumber("count").longValue();
+      long countDelta = data.getJsonNumber("countDelta").longValue();
       int depth = data.getInt("messageCount");
       int depthDelta = data.getInt("messageCountDelta");
       String lastAddTimestamp = data.getString("lastAddTimestamp");
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/management/impl/AddressControlImpl.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/management/impl/AddressControlImpl.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/management/impl/AddressControlImpl.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/management/impl/AddressControlImpl.java	2016-07-18 11:22:05.600770768 +0200
@@ -12,6 +12,8 @@
  */
 package org.hornetq.core.management.impl;
 
+import javax.json.Json;
+import javax.json.JsonArrayBuilder;
 import javax.management.MBeanOperationInfo;
 import java.util.ArrayList;
 import java.util.List;
@@ -29,8 +31,6 @@
 import org.hornetq.core.security.CheckType;
 import org.hornetq.core.security.Role;
 import org.hornetq.core.settings.HierarchicalRepository;
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
 
 /**
  * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
@@ -161,12 +161,12 @@
       clearIO();
       try
       {
-         JSONArray json = new JSONArray();
+         JsonArrayBuilder json = Json.createArrayBuilder();
          Set<Role> roles = securityRepository.getMatch(address.toString());
 
          for (Role role : roles)
          {
-            json.put(new JSONObject(role));
+            json.add(role.toJson());
          }
          return json.toString();
       }
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/management/impl/BroadcastGroupControlImpl.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/management/impl/BroadcastGroupControlImpl.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/management/impl/BroadcastGroupControlImpl.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/management/impl/BroadcastGroupControlImpl.java	2016-07-18 11:24:27.649059616 +0200
@@ -15,11 +15,11 @@
 import javax.management.MBeanOperationInfo;
 
 import org.hornetq.api.core.BroadcastGroupConfiguration;
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.api.core.UDPBroadcastGroupConfiguration;
 import org.hornetq.api.core.management.BroadcastGroupControl;
 import org.hornetq.core.persistence.StorageManager;
 import org.hornetq.core.server.cluster.BroadcastGroup;
-import org.hornetq.utils.json.JSONArray;
 
 /**
  * A BroadcastGroupControl
@@ -106,13 +106,7 @@
       clearIO();
       try
       {
-         JSONArray array = new JSONArray();
-
-         for (String connector : configuration.getConnectorInfos())
-         {
-            array.put(connector);
-         }
-         return array.toString();
+         return JsonUtil.toJsonArray(configuration.getConnectorInfos()).toString();
       }
       finally
       {
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/management/impl/ClusterConnectionControlImpl.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/management/impl/ClusterConnectionControlImpl.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/management/impl/ClusterConnectionControlImpl.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/management/impl/ClusterConnectionControlImpl.java	2016-07-18 11:25:52.117068879 +0200
@@ -16,11 +16,11 @@
 import java.util.List;
 import java.util.Map;
 
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.api.core.management.ClusterConnectionControl;
 import org.hornetq.core.config.ClusterConnectionConfiguration;
 import org.hornetq.core.persistence.StorageManager;
 import org.hornetq.core.server.cluster.ClusterConnection;
-import org.hornetq.utils.json.JSONArray;
 
 /**
  * A ClusterConnectionControl
@@ -161,20 +161,7 @@
       clearIO();
       try
       {
-         List<String> connectors = configuration.getStaticConnectors();
-
-         if (connectors == null)
-         {
-            return null;
-         }
-
-         JSONArray array = new JSONArray();
-
-         for (String connector : connectors)
-         {
-            array.put(connector);
-         }
-         return array.toString();
+         return JsonUtil.toJsonArray(configuration.getStaticConnectors()).toString();
       }
       finally
       {
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/management/impl/HornetQServerControlImpl.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/management/impl/HornetQServerControlImpl.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/management/impl/HornetQServerControlImpl.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/management/impl/HornetQServerControlImpl.java	2016-07-18 13:28:35.139574387 +0200
@@ -26,6 +26,11 @@
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
 
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
 import javax.management.ListenerNotFoundException;
 import javax.management.MBeanNotificationInfo;
 import javax.management.MBeanOperationInfo;
@@ -80,8 +85,6 @@
 import org.hornetq.spi.core.protocol.RemotingConnection;
 import org.hornetq.utils.SecurityFormatter;
 import org.hornetq.utils.TypedProperties;
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
 
 /**
  * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
@@ -978,7 +981,7 @@
             }
          });
 
-         JSONArray txDetailListJson = new JSONArray();
+         JsonArrayBuilder txDetailListJson = Json.createArrayBuilder();
          for (Map.Entry<Xid, Long> entry : xidsSortedByCreationTime)
          {
             Xid xid = entry.getKey();
@@ -986,9 +989,9 @@
                   resourceManager.getTransaction(xid),
                   entry.getValue());
 
-            txDetailListJson.put(detail.toJSON());
+            txDetailListJson.add(detail.toJSON());
          }
-         return txDetailListJson.toString();
+         return txDetailListJson.build().toString();
       }
       finally
       {
@@ -1029,7 +1032,7 @@
                   resourceManager.getTransaction(xid),
                   entry.getValue());
 
-            JSONObject txJson = detail.toJSON();
+            JsonObject txJson = detail.toJSON();
 
             html.append("<table border=\"1\">");
             html.append("<tr><th>creation_time</th>");
@@ -1047,17 +1050,13 @@
             html.append("<tr><td colspan=\"6\">");
             html.append("<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">");
 
-            JSONArray msgs = txJson.getJSONArray(TransactionDetail.KEY_TX_RELATED_MESSAGES);
-            for (int i = 0; i < msgs.length(); i++)
-            {
-               JSONObject msgJson = msgs.getJSONObject(i);
-               JSONObject props = msgJson.getJSONObject(TransactionDetail.KEY_MSG_PROPERTIES);
+            JsonArray msgs = txJson.getJsonArray(TransactionDetail.KEY_TX_RELATED_MESSAGES);
+            for (int i = 0; i < msgs.size(); i++) {
+               JsonObject msgJson = msgs.getJsonObject(i);
+               JsonObject props = msgJson.getJsonObject(TransactionDetail.KEY_MSG_PROPERTIES);
                StringBuilder propstr = new StringBuilder();
-               @SuppressWarnings("unchecked")
-               Iterator<String> propkeys = props.keys();
-               while (propkeys.hasNext())
-               {
-                  String key = propkeys.next();
+               Set<String> keys = props.keySet();
+               for (String key : keys) {
                   propstr.append(key);
                   propstr.append("=");
                   propstr.append(props.get(key));
@@ -1403,7 +1402,7 @@
    */
    public String listProducersInfoAsJSON() throws Exception
    {
-      JSONArray producers = new JSONArray();
+      JsonArrayBuilder producers = Json.createArrayBuilder();
 
 
       for (ServerSession session : server.getSessions())
@@ -1411,7 +1410,7 @@
          session.describeProducersInfo(producers);
       }
 
-      return producers.toString();
+      return producers.build().toString();
    }
 
 
@@ -1454,14 +1453,14 @@
       clearIO();
       try
       {
-         JSONArray array = new JSONArray();
+         JsonArrayBuilder array = Json.createArrayBuilder();
 
          for (TransportConfiguration config : configuration.getConnectorConfigurations().values())
          {
-            array.put(new JSONObject(config));
+            array.add(config.toJson());
          }
 
-         return array.toString();
+         return array.build().toString();
       }
       finally
       {
@@ -1566,12 +1565,12 @@
       clearIO();
       try
       {
-         JSONArray json = new JSONArray();
+         JsonArrayBuilder json = Json.createArrayBuilder();
          Set<Role> roles = server.getSecurityRepository().getMatch(addressMatch);
 
          for (Role role : roles)
          {
-            json.put(new JSONObject(role));
+            json.add(role.toJson());
          }
          return json.toString();
       }
@@ -1586,39 +1585,38 @@
       checkStarted();
 
       AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch(address);
-      Map<String, Object> settings = new HashMap<String, Object>();
+      String policy = addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.PAGE ? "PAGE" : addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.BLOCK ? "BLOCK" : addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.DROP ? "DROP" : "FAIL";
+      String consumerPolicy = addressSettings.getSlowConsumerPolicy() == SlowConsumerPolicy.NOTIFY ? "NOTIFY" : "KILL";
+      JsonObjectBuilder settings = Json.createObjectBuilder();
       if (addressSettings.getDeadLetterAddress() != null)
       {
-         settings.put("DLA", addressSettings.getDeadLetterAddress());
+         settings.add("DLA", addressSettings.getDeadLetterAddress().toString());
       }
       if (addressSettings.getExpiryAddress() != null)
       {
-         settings.put("expiryAddress", addressSettings.getExpiryAddress());
+         settings.add("expiryAddress", addressSettings.getExpiryAddress().toString());
       }
-      settings.put("expiryDelay", addressSettings.getExpiryDelay());
-      settings.put("maxDeliveryAttempts", addressSettings.getMaxDeliveryAttempts());
-      settings.put("pageCacheMaxSize", addressSettings.getPageCacheMaxSize());
-      settings.put("maxSizeBytes", addressSettings.getMaxSizeBytes());
-      settings.put("pageSizeBytes", addressSettings.getPageSizeBytes());
-      settings.put("redeliveryDelay", addressSettings.getRedeliveryDelay());
-      settings.put("redeliveryMultiplier", addressSettings.getRedeliveryMultiplier());
-      settings.put("maxRedeliveryDelay", addressSettings.getMaxRedeliveryDelay());
-      settings.put("redistributionDelay", addressSettings.getRedistributionDelay());
-      settings.put("lastValueQueue", addressSettings.isLastValueQueue());
-      settings.put("sendToDLAOnNoRoute", addressSettings.isSendToDLAOnNoRoute());
-      String policy = addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.PAGE ? "PAGE"
-            : addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.BLOCK ? "BLOCK"
-            : addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.DROP ? "DROP"
-            : "FAIL";
-      settings.put("addressFullMessagePolicy", policy);
-      settings.put("slowConsumerThreshold", addressSettings.getSlowConsumerThreshold());
-      settings.put("slowConsumerCheckPeriod", addressSettings.getSlowConsumerCheckPeriod());
-      policy = addressSettings.getSlowConsumerPolicy() == SlowConsumerPolicy.NOTIFY ? "NOTIFY"
-         : "KILL";
-      settings.put("slowConsumerPolicy", policy);
-
-      JSONObject jsonObject = new JSONObject(settings);
-      return jsonObject.toString();
+      return settings
+         .add("expiryDelay", addressSettings.getExpiryDelay())
+         .add("maxDeliveryAttempts", addressSettings.getMaxDeliveryAttempts())
+         .add("pageCacheMaxSize", addressSettings.getPageCacheMaxSize())
+         .add("maxSizeBytes", addressSettings.getMaxSizeBytes())
+         .add("pageSizeBytes", addressSettings.getPageSizeBytes())
+         .add("redeliveryDelay", addressSettings.getRedeliveryDelay())
+         .add("redeliveryMultiplier", addressSettings.getRedeliveryMultiplier())
+         .add("maxRedeliveryDelay", addressSettings.getMaxRedeliveryDelay())
+         .add("redistributionDelay", addressSettings.getRedistributionDelay())
+         .add("lastValueQueue", addressSettings.isLastValueQueue())
+         .add("sendToDLAOnNoRoute", addressSettings.isSendToDLAOnNoRoute())
+         .add("addressFullMessagePolicy", policy)
+         .add("slowConsumerThreshold", addressSettings.getSlowConsumerThreshold())
+         .add("slowConsumerCheckPeriod", addressSettings.getSlowConsumerCheckPeriod())
+         .add("slowConsumerPolicy", consumerPolicy)
+         .build().toString();
+         //.add("autoCreateJmsQueues", addressSettings.isAutoCreateJmsQueues())
+         //.add("autoDeleteJmsQueues", addressSettings.isAutoDeleteJmsQueues())
+         //.add("autoCreateJmsTopics", addressSettings.isAutoCreateJmsTopics())
+         //.add("autoDeleteJmsTopics", addressSettings.isAutoDeleteJmsTopics())
    }
 
 
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/management/impl/QueueControlImpl.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/management/impl/QueueControlImpl.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/management/impl/QueueControlImpl.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/management/impl/QueueControlImpl.java	2016-07-18 11:30:51.464878518 +0200
@@ -12,6 +12,10 @@
  */
 package org.hornetq.core.management.impl;
 
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObjectBuilder;
 import javax.management.MBeanOperationInfo;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -20,6 +24,7 @@
 import java.util.Map;
 
 import org.hornetq.api.core.HornetQException;
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.api.core.Message;
 import org.hornetq.api.core.SimpleString;
 import org.hornetq.api.core.management.MessageCounterInfo;
@@ -39,9 +44,6 @@
 import org.hornetq.core.settings.HierarchicalRepository;
 import org.hornetq.core.settings.impl.AddressSettings;
 import org.hornetq.utils.LinkedListIterator;
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONException;
-import org.hornetq.utils.json.JSONObject;
 
 /**
  * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
@@ -67,39 +69,30 @@
 
    private static String toJSON(final Map<String, Object>[] messages)
    {
-      JSONArray array = toJSONMsgArray(messages);
+      JsonArray array = toJSONMsgArray(messages);
       return array.toString();
    }
 
-   private static JSONArray toJSONMsgArray(final Map<String, Object>[] messages)
-   {
-      JSONArray array = new JSONArray();
+   private static JsonArray toJSONMsgArray(final Map<String, Object>[] messages) {
+      JsonArrayBuilder array = Json.createArrayBuilder();
       for (Map<String, Object> message : messages)
       {
-         array.put(new JSONObject(message));
+         array.add(JsonUtil.toJsonObject(message));
       }
-      return array;
+      return array.build();
    }
 
    private static String toJSON(final Map<String, Map<String, Object>[]> messages)
    {
-      try
-      {
-         JSONArray arrayReturn = new JSONArray();
-         for (Map.Entry<String, Map<String, Object>[]> entry : messages.entrySet())
-         {
-            JSONObject objectItem = new JSONObject();
-            objectItem.put("consumerName", entry.getKey());
-            objectItem.put("elements", toJSONMsgArray(entry.getValue()));
-            arrayReturn.put(objectItem);
-         }
-
-         return arrayReturn.toString();
-      }
-      catch (JSONException e)
-      {
-         return "Invalid conversion " + e.toString();
+      JsonArrayBuilder arrayReturn = Json.createArrayBuilder();
+      for (Map.Entry<String, Map<String, Object>[]> entry : messages.entrySet()) {
+         JsonObjectBuilder objectItem = Json.createObjectBuilder();
+         objectItem.add("consumerName", entry.getKey());
+         objectItem.add("elements", toJSONMsgArray(entry.getValue()));
+         arrayReturn.add(objectItem);
       }
+
+      return arrayReturn.build().toString();
    }
 
 
@@ -936,7 +929,7 @@
       {
          Collection<Consumer> consumers = queue.getConsumers();
 
-         JSONArray jsonArray = new JSONArray();
+         JsonArrayBuilder jsonArray = Json.createArrayBuilder();
 
          for (Consumer consumer : consumers)
          {
@@ -945,14 +938,14 @@
             {
                ServerConsumer serverConsumer = (ServerConsumer) consumer;
 
-               JSONObject obj = new JSONObject();
-               obj.put("consumerID", serverConsumer.getID());
-               obj.put("connectionID", serverConsumer.getConnectionID().toString());
-               obj.put("sessionID", serverConsumer.getSessionID());
-               obj.put("browseOnly", serverConsumer.isBrowseOnly());
-               obj.put("creationTime", serverConsumer.getCreationTime());
+               JsonObjectBuilder obj = Json.createObjectBuilder()
+                  .add("consumerID", serverConsumer.getID())
+                  .add("connectionID", serverConsumer.getConnectionID().toString())
+                  .add("sessionID", serverConsumer.getSessionID())
+                  .add("browseOnly", serverConsumer.isBrowseOnly())
+                  .add("creationTime", serverConsumer.getCreationTime());
 
-               jsonArray.put(obj);
+               jsonArray.add(obj);
             }
 
          }
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/server/impl/ServerSessionImpl.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/server/impl/ServerSessionImpl.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/server/impl/ServerSessionImpl.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/server/impl/ServerSessionImpl.java	2016-07-18 11:36:24.928064302 +0200
@@ -24,6 +24,9 @@
 
 package org.hornetq.core.server.impl;
 
+import javax.json.Json;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObjectBuilder;
 import javax.transaction.xa.XAException;
 import javax.transaction.xa.Xid;
 import java.util.ArrayList;
@@ -86,8 +89,6 @@
 import org.hornetq.spi.core.protocol.SessionCallback;
 import org.hornetq.utils.TypedProperties;
 import org.hornetq.utils.UUID;
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
 
 /**
  * Server side Session implementation
@@ -1525,19 +1526,18 @@
    }
 
    @Override
-   public void describeProducersInfo(JSONArray array) throws Exception
-   {
+   public void describeProducersInfo(JsonArrayBuilder array) throws Exception {
       Map<SimpleString, Pair<UUID, AtomicLong>> targetCopy = cloneTargetAddresses();
 
       for (Map.Entry<SimpleString, Pair<UUID, AtomicLong>> entry : targetCopy.entrySet())
       {
-         JSONObject producerInfo = new JSONObject();
-         producerInfo.put("connectionID", this.getConnectionID().toString());
-         producerInfo.put("sessionID", this.getName());
-         producerInfo.put("destination", entry.getKey().toString());
-         producerInfo.put("lastUUIDSent", entry.getValue().getA());
-         producerInfo.put("msgSent", entry.getValue().getB().longValue());
-         array.put(producerInfo);
+         JsonObjectBuilder producerInfo = Json.createObjectBuilder()
+            .add("connectionID", this.getConnectionID().toString())
+            .add("sessionID", this.getName())
+            .add("destination", entry.getKey().toString())
+            .add("lastUUIDSent", entry.getValue().getA().toString())
+            .add("msgSent", entry.getValue().getB().longValue());
+         array.add(producerInfo);
       }
    }
 
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/server/ServerSession.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/server/ServerSession.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/server/ServerSession.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/server/ServerSession.java	2016-07-18 11:32:19.373710419 +0200
@@ -12,6 +12,7 @@
  */
 package org.hornetq.core.server;
 
+import javax.json.JsonArrayBuilder;
 import javax.transaction.xa.Xid;
 import java.util.List;
 import java.util.Set;
@@ -21,7 +22,6 @@
 import org.hornetq.core.persistence.OperationContext;
 import org.hornetq.core.transaction.Transaction;
 import org.hornetq.spi.core.protocol.RemotingConnection;
-import org.hornetq.utils.json.JSONArray;
 
 /**
  * A ServerSession
@@ -138,7 +138,7 @@
     * @param objs
     * @throws Exception
     */
-   void describeProducersInfo(JSONArray objs) throws Exception;
+   void describeProducersInfo(JsonArrayBuilder objs) throws Exception;
 
    String getLastSentMessageID(String address);
 
diff -Nru hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/transaction/TransactionDetail.java hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/transaction/TransactionDetail.java
--- hornetq-HornetQ_2_4_7_Final/hornetq-server/src/main/java/org/hornetq/core/transaction/TransactionDetail.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/hornetq-server/src/main/java/org/hornetq/core/transaction/TransactionDetail.java	2016-07-18 11:40:51.608410621 +0200
@@ -17,13 +17,16 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.json.Json;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
 import javax.transaction.xa.Xid;
 
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.core.server.MessageReference;
 import org.hornetq.core.server.ServerMessage;
 import org.hornetq.core.transaction.impl.XidImpl;
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
 
 /**
  * A TransactionDetail
@@ -63,23 +66,21 @@
       this.creationTime = creation;
    }
 
-   public JSONObject toJSON() throws Exception
-   {
+   public JsonObject toJSON() throws Exception {
       DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
-      JSONObject detailJson = new JSONObject();
-
-      detailJson.put(KEY_CREATION_TIME, dateFormat.format(new Date(this.creationTime)));
-      detailJson.put(KEY_XID_AS_BASE64, XidImpl.toBase64String(this.xid));
-      detailJson.put(KEY_XID_FORMAT_ID, this.xid.getFormatId());
-      detailJson.put(KEY_XID_GLOBAL_TXID, new String(this.xid.getGlobalTransactionId()));
-      detailJson.put(KEY_XID_BRANCH_QUAL, new String(this.xid.getBranchQualifier()));
+      JsonObjectBuilder detailJson = Json.createObjectBuilder()
+         .add(KEY_CREATION_TIME, dateFormat.format(new Date(this.creationTime)))
+         .add(KEY_XID_AS_BASE64, XidImpl.toBase64String(this.xid))
+         .add(KEY_XID_FORMAT_ID, this.xid.getFormatId())
+         .add(KEY_XID_GLOBAL_TXID, new String(this.xid.getGlobalTransactionId()))
+         .add(KEY_XID_BRANCH_QUAL, new String(this.xid.getBranchQualifier()));
 
-      JSONArray msgsJson = new JSONArray();
+      JsonArrayBuilder msgsJson = Json.createArrayBuilder();
       List<TransactionOperation> txops = this.transaction.getAllOperations();
-      detailJson.put(KEY_TX_RELATED_MESSAGES, msgsJson);
+
       if (txops == null)
       {
-         return detailJson;
+         return detailJson.build();
       }
 
       for (TransactionOperation op : txops)
@@ -103,18 +104,19 @@
 
          for (MessageReference ref : msgs)
          {
-            JSONObject msgJson = new JSONObject();
-            msgsJson.put(msgJson);
+            JsonObjectBuilder msgJson = Json.createObjectBuilder();
+            msgsJson.add(msgJson);
 
-            msgJson.put(KEY_MSG_OP_TYPE, opType);
+            msgJson.add(KEY_MSG_OP_TYPE, opType);
 
             ServerMessage msg = ref.getMessage().copy();
 
-            msgJson.put(KEY_MSG_TYPE, decodeMessageType(msg));
-            msgJson.put(KEY_MSG_PROPERTIES, decodeMessageProperties(msg));
+            msgJson.add(KEY_MSG_TYPE, decodeMessageType(msg));
+            JsonUtil.addToObject(KEY_MSG_PROPERTIES, decodeMessageProperties(msg), msgJson);
          }
       }
-      return detailJson;
+      detailJson.add(KEY_TX_RELATED_MESSAGES, msgsJson);
+      return detailJson.build();
    }
 
    public abstract String decodeMessageType(ServerMessage msg);
diff -Nru hornetq-HornetQ_2_4_7_Final/tests/integration-tests/pom.xml hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/pom.xml
--- hornetq-HornetQ_2_4_7_Final/tests/integration-tests/pom.xml	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/pom.xml	2016-07-18 12:16:45.486042047 +0200
@@ -162,6 +162,12 @@
          <groupId>org.jboss.jbossts.jts</groupId>
          <artifactId>jbossjts-jacorb</artifactId>
       </dependency>
+      <dependency>
+         <groupId>org.apache.geronimo.specs</groupId>
+         <artifactId>geronimo-json_1.0_spec</artifactId>
+         <version>1.0-alpha-1</version>
+         <scope>test</scope>
+      </dependency>
    </dependencies>
 
    <build>
diff -Nru hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/aerogear/AeroGearBasicServerTest.java hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/aerogear/AeroGearBasicServerTest.java
--- hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/aerogear/AeroGearBasicServerTest.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/aerogear/AeroGearBasicServerTest.java	2016-07-18 11:46:36.280040524 +0200
@@ -13,6 +13,8 @@
 package org.hornetq.tests.integration.aerogear;
 
 
+import javax.json.JsonArray;
+import javax.json.JsonObject;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -21,6 +23,7 @@
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.api.core.Message;
 import org.hornetq.api.core.TransportConfiguration;
 import org.hornetq.api.core.client.ClientConsumer;
@@ -39,9 +42,6 @@
 import org.hornetq.integration.aerogear.AeroGearConstants;
 import org.hornetq.tests.util.ServiceTestBase;
 import org.hornetq.tests.util.UnitTestCase;
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONException;
-import org.hornetq.utils.json.JSONObject;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -134,7 +134,7 @@
 
       assertTrue(latch.await(5, TimeUnit.SECONDS));
       assertNotNull(aeroGearHandler.jsonObject);
-      JSONObject body = (JSONObject) aeroGearHandler.jsonObject.get("message");
+      JsonObject body = (JsonObject) aeroGearHandler.jsonObject.get("message");
       assertNotNull(body);
       String prop1 = body.getString("AEROGEAR_PROP1");
       assertNotNull(prop1);
@@ -154,16 +154,16 @@
       Integer ttl = body.getInt("ttl");
       assertNotNull(ttl);
       assertEquals(ttl.intValue(), 3600);
-      JSONArray jsonArray = (JSONArray) aeroGearHandler.jsonObject.get("variants");
+      JsonArray jsonArray = (JsonArray) aeroGearHandler.jsonObject.get("variants");
       assertNotNull(jsonArray);
       assertEquals(jsonArray.getString(0), "variant1");
       assertEquals(jsonArray.getString(1), "variant2");
-      jsonArray = (JSONArray) aeroGearHandler.jsonObject.get("alias");
+      jsonArray = (JsonArray) aeroGearHandler.jsonObject.get("alias");
       assertNotNull(jsonArray);
       assertEquals(jsonArray.getString(0), "me");
       assertEquals(jsonArray.getString(1), "him");
       assertEquals(jsonArray.getString(2), "them");
-      jsonArray = (JSONArray) aeroGearHandler.jsonObject.get("deviceType");
+      jsonArray = (JsonArray) aeroGearHandler.jsonObject.get("deviceType");
       assertNotNull(jsonArray);
       assertEquals(jsonArray.getString(0), "android");
       assertEquals(jsonArray.getString(1), "ipad");
@@ -183,7 +183,7 @@
       producer.send(m);
       assertTrue(latch.await(5, TimeUnit.SECONDS));
       assertNotNull(aeroGearHandler.jsonObject);
-      body = (JSONObject) aeroGearHandler.jsonObject.get("message");
+      body = (JsonObject) aeroGearHandler.jsonObject.get("message");
       assertNotNull(body);
       alert = body.getString("alert");
       assertNotNull(alert);
@@ -197,15 +197,15 @@
       ttl = body.getInt("ttl");
       assertNotNull(ttl);
       assertEquals(ttl.intValue(), 10000);
-      jsonArray = (JSONArray) aeroGearHandler.jsonObject.get("variants");
+      jsonArray = (JsonArray) aeroGearHandler.jsonObject.get("variants");
       assertNotNull(jsonArray);
       assertEquals(jsonArray.getString(0), "v1");
       assertEquals(jsonArray.getString(1), "v2");
-      jsonArray = (JSONArray) aeroGearHandler.jsonObject.get("alias");
+      jsonArray = (JsonArray) aeroGearHandler.jsonObject.get("alias");
       assertNotNull(jsonArray);
       assertEquals(jsonArray.getString(0), "alias1");
       assertEquals(jsonArray.getString(1), "alias2");
-      jsonArray = (JSONArray) aeroGearHandler.jsonObject.get("deviceType");
+      jsonArray = (JsonArray) aeroGearHandler.jsonObject.get("deviceType");
       assertNotNull(jsonArray);
       assertEquals(jsonArray.getString(0), "dev1");
       assertEquals(jsonArray.getString(1), "dev2");
@@ -216,7 +216,7 @@
 
    class AeroGearHandler extends AbstractHandler
    {
-      JSONObject jsonObject;
+      JsonObject jsonObject;
       private CountDownLatch latch;
 
       public AeroGearHandler(CountDownLatch latch)
@@ -234,14 +234,7 @@
          byte[] bytes = new byte[httpServletRequest.getContentLength()];
          httpServletRequest.getInputStream().read(bytes);
          String json = new String(bytes);
-         try
-         {
-            jsonObject = new JSONObject(json);
-         }
-         catch (JSONException e)
-         {
-            jsonObject = null;
-         }
+         jsonObject = JsonUtil.readJsonObject(json);
          latch.countDown();
       }
 
diff -Nru hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java
--- hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java	2016-07-18 11:49:53.735654839 +0200
@@ -18,6 +18,7 @@
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
+import javax.json.JsonArray;
 import javax.management.Notification;
 import javax.naming.Context;
 
@@ -27,6 +28,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.api.core.SimpleString;
 import org.hornetq.api.core.TransportConfiguration;
 import org.hornetq.api.core.client.ClientConsumer;
@@ -56,7 +58,6 @@
 import org.hornetq.tests.unit.util.InVMNamingContext;
 import org.hornetq.tests.util.RandomUtil;
 import org.hornetq.utils.UUIDGenerator;
-import org.hornetq.utils.json.JSONArray;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -106,9 +107,9 @@
 
       Assert.assertEquals(1, queueControl.getConsumerCount());
 
-      JSONArray jsonArray = new JSONArray(queueControl.listConsumersAsJSON());
+      JsonArray jsonArray = JsonUtil.readJsonArray(queueControl.listConsumersAsJSON());
 
-      assertEquals(1, jsonArray.length());
+      assertEquals(1, jsonArray.size());
 
       JMSUtil.sendMessages(queue, 2);
 
@@ -216,17 +217,17 @@
 
       String jsonString = queueControl.listMessagesAsJSON(null);
       Assert.assertNotNull(jsonString);
-      JSONArray array = new JSONArray(jsonString);
-      Assert.assertEquals(2, array.length());
-      Assert.assertEquals(ids[0], array.getJSONObject(0).get("JMSMessageID"));
-      Assert.assertEquals(ids[1], array.getJSONObject(1).get("JMSMessageID"));
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(2, array.size());
+      Assert.assertEquals(ids[0], array.getJsonObject(0).get("JMSMessageID"));
+      Assert.assertEquals(ids[1], array.getJsonObject(1).get("JMSMessageID"));
 
       JMSUtil.consumeMessages(2, queue);
 
       jsonString = queueControl.listMessagesAsJSON(null);
       Assert.assertNotNull(jsonString);
-      array = new JSONArray(jsonString);
-      Assert.assertEquals(0, array.length());
+      array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(0, array.size());
    }
 
    @Test
diff -Nru hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java
--- hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java	2016-07-18 11:52:44.508532198 +0200
@@ -25,6 +25,7 @@
 import javax.jms.XAConnection;
 import javax.jms.XAConnectionFactory;
 import javax.jms.XASession;
+import javax.json.JsonArray;
 import javax.naming.NamingException;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
@@ -36,6 +37,7 @@
 
 import org.hornetq.api.config.HornetQDefaultConfiguration;
 import org.hornetq.api.core.HornetQObjectClosedException;
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.api.core.SimpleString;
 import org.hornetq.api.core.TransportConfiguration;
 import org.hornetq.api.core.client.HornetQClient;
@@ -65,7 +67,6 @@
 import org.hornetq.tests.unit.util.InVMNamingContext;
 import org.hornetq.tests.util.RandomUtil;
 import org.hornetq.tests.util.UnitTestCase;
-import org.hornetq.utils.json.JSONArray;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -695,15 +696,15 @@
       // create a consumer will create a Core queue bound to the topic address
       MessageConsumer cons = session.createConsumer(topic);
 
-      JSONArray jsonArray = new JSONArray(control.listAllConsumersAsJSON());
+      JsonArray jsonArray = JsonUtil.readJsonArray(control.listAllConsumersAsJSON());
 
-      assertEquals(1 + getNumberOfConsumers(), jsonArray.length());
+      Assert.assertEquals(1 + getNumberOfConsumers(), jsonArray.size());
 
       cons.close();
 
-      jsonArray = new JSONArray(control.listAllConsumersAsJSON());
+      jsonArray = JsonUtil.readJsonArray(control.listAllConsumersAsJSON());
 
-      assertEquals(getNumberOfConsumers(), jsonArray.length());
+      Assert.assertEquals(getNumberOfConsumers(), jsonArray.size());
 
       String topicAddress = HornetQDestination.createTopicAddressFromName(topicName).toString();
       AddressControl addressControl = (AddressControl) server.getManagementService()
diff -Nru hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/management/TopicControlTest.java hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/management/TopicControlTest.java
--- hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/management/TopicControlTest.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/jms/server/management/TopicControlTest.java	2016-07-18 11:55:18.488190010 +0200
@@ -19,12 +19,14 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.jms.TopicSubscriber;
+import javax.json.JsonArray;
 import javax.management.Notification;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.api.core.TransportConfiguration;
 import org.hornetq.api.core.management.ObjectNameBuilder;
 import org.hornetq.api.jms.HornetQJMSClient;
@@ -43,7 +45,6 @@
 import org.hornetq.tests.integration.management.ManagementTestBase;
 import org.hornetq.tests.unit.util.InVMNamingContext;
 import org.hornetq.tests.util.RandomUtil;
-import org.hornetq.utils.json.JSONArray;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -163,9 +164,9 @@
 
       String json = topicControl.listAllSubscriptionsAsJSON();
       System.out.println("Json: " + json);
-      JSONArray jsonArray = new JSONArray(json);
+      JsonArray jsonArray = JsonUtil.readJsonArray(json);
 
-      assertEquals(3, jsonArray.length());
+      Assert.assertEquals(3, jsonArray.size());
 
       connection_1.close();
       connection_2.close();
@@ -421,11 +422,11 @@
       String jsonString = topicControl.listMessagesForSubscriptionAsJSON(HornetQDestination.createQueueNameForDurableSubscription(true, clientID,
                                                                                                                                   subscriptionName));
       Assert.assertNotNull(jsonString);
-      JSONArray array = new JSONArray(jsonString);
-      Assert.assertEquals(3, array.length());
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(3, array.size());
       for (int i = 0; i < 3; i++)
       {
-         Assert.assertEquals(ids[i], array.getJSONObject(i).get("JMSMessageID"));
+         Assert.assertEquals(ids[i], array.getJsonObject(i).get("JMSMessageID").toString());
       }
 
       connection.close();
diff -Nru hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BroadcastGroupControlTest.java hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BroadcastGroupControlTest.java
--- hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BroadcastGroupControlTest.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/BroadcastGroupControlTest.java	2016-07-18 12:01:40.401996246 +0200
@@ -16,10 +16,12 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import javax.json.JsonArray;
 
 import org.junit.Assert;
 
 import org.hornetq.api.core.BroadcastGroupConfiguration;
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.api.core.TransportConfiguration;
 import org.hornetq.api.core.UDPBroadcastGroupConfiguration;
 import org.hornetq.api.core.management.BroadcastGroupControl;
@@ -28,7 +30,6 @@
 import org.hornetq.core.server.HornetQServers;
 import org.hornetq.tests.util.RandomUtil;
 import org.hornetq.api.core.Pair;
-import org.hornetq.utils.json.JSONArray;
 
 /**
  * @author <a href="jmesnil@redhat.com">Jeff Mesnil</a>
@@ -90,8 +91,8 @@
       Assert.assertEquals(broadcastGroupConfig.getConnectorInfos().get(0), connectorPairData);
       String jsonString = broadcastGroupControl.getConnectorPairsAsJSON();
       Assert.assertNotNull(jsonString);
-      JSONArray array = new JSONArray(jsonString);
-      Assert.assertEquals(1, array.length());
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(1, array.size());
       Assert.assertEquals(broadcastGroupConfig.getConnectorInfos().get(0), array.getString(0));
 
       Assert.assertTrue(broadcastGroupControl.isStarted());
diff -Nru hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ClusterConnectionControlTest.java hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ClusterConnectionControlTest.java
--- hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ClusterConnectionControlTest.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ClusterConnectionControlTest.java	2016-07-18 12:03:08.241833646 +0200
@@ -20,11 +20,13 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.json.JsonArray;
 import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;
 
 import org.junit.Assert;
 import org.hornetq.api.core.DiscoveryGroupConfiguration;
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.api.core.SimpleString;
 import org.hornetq.api.core.TransportConfiguration;
 import org.hornetq.api.core.UDPBroadcastGroupConfiguration;
@@ -42,7 +44,6 @@
 import org.hornetq.core.server.management.Notification;
 import org.hornetq.tests.integration.SimpleNotificationService;
 import org.hornetq.tests.util.RandomUtil;
-import org.hornetq.utils.json.JSONArray;
 
 /**
  * A BridgeControlTest
@@ -98,8 +99,8 @@
 
       String jsonString = clusterConnectionControl.getStaticConnectorsAsJSON();
       Assert.assertNotNull(jsonString);
-      JSONArray array = new JSONArray(jsonString);
-      Assert.assertEquals(1, array.length());
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(1, array.size());
       Assert.assertEquals(clusterConnectionConfig1.getStaticConnectors().get(0), array.getString(0));
 
       Assert.assertNull(clusterConnectionControl.getDiscoveryGroupName());
diff -Nru hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/HornetQServerControlTest.java hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/HornetQServerControlTest.java
--- hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/HornetQServerControlTest.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/HornetQServerControlTest.java	2016-07-18 11:59:48.533313491 +0200
@@ -12,11 +12,14 @@
  */
 package org.hornetq.tests.integration.management;
 
+import javax.json.JsonArray;
+import javax.json.JsonObject;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.api.core.SimpleString;
 import org.hornetq.api.core.TransportConfiguration;
 import org.hornetq.api.core.client.ClientConsumer;
@@ -45,8 +48,6 @@
 import org.hornetq.tests.util.RandomUtil;
 import org.hornetq.tests.util.UnitTestCase;
 import org.hornetq.utils.UUIDGenerator;
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -169,12 +170,12 @@
 
       String jsonString = serverControl.getConnectorsAsJSON();
       Assert.assertNotNull(jsonString);
-      JSONArray array = new JSONArray(jsonString);
-      Assert.assertEquals(1, array.length());
-      JSONObject data = array.getJSONObject(0);
-      Assert.assertEquals(connectorConfig.getName(), data.optString("name"));
-      Assert.assertEquals(connectorConfig.getFactoryClassName(), data.optString("factoryClassName"));
-      Assert.assertEquals(connectorConfig.getParams().size(), data.getJSONObject("params").length());
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(1, array.size());
+      JsonObject data = array.getJsonObject(0);
+      Assert.assertEquals(connectorConfig.getName(), data.getString("name"));
+      Assert.assertEquals(connectorConfig.getFactoryClassName(), data.getString("factoryClassName"));
+      Assert.assertEquals(connectorConfig.getParams().size(), data.getJsonObject("params").size());
    }
 
    @Test
@@ -855,10 +856,10 @@
 
       HornetQServerControl serverControl = createManagementControl();
 
-      JSONArray jsonArray = new JSONArray(serverControl.listProducersInfoAsJSON());
+      JsonArray jsonArray = JsonUtil.readJsonArray(serverControl.listProducersInfoAsJSON());
 
-      assertEquals(1, jsonArray.length());
-      assertEquals(4, ((JSONObject) jsonArray.get(0)).getInt("msgSent"));
+      assertEquals(1, jsonArray.size());
+      assertEquals(4, ((JsonObject) jsonArray.get(0)).getInt("msgSent"));
 
       clientSession.close();
       locator.close();
diff -Nru hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ManagementHelperTest.java hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ManagementHelperTest.java
--- hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ManagementHelperTest.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ManagementHelperTest.java	2016-07-18 12:04:36.816636217 +0200
@@ -232,90 +232,6 @@
 
    }
 
-   @Test
-   public void testFromCommaSeparatedKeyValues() throws Exception
-   {
-      String str = "key1=1, key2=false, key3=2.0, key4=whatever";
-
-      Map<String, Object> map = ManagementHelper.fromCommaSeparatedKeyValues(str);
-      Assert.assertEquals(4, map.size());
-      Assert.assertTrue(map.containsKey("key1"));
-      Assert.assertEquals(1L, map.get("key1"));
-
-      Assert.assertTrue(map.containsKey("key2"));
-      Assert.assertEquals(false, map.get("key2"));
-
-      Assert.assertTrue(map.containsKey("key3"));
-      Assert.assertEquals(2.0, map.get("key3"));
-
-      Assert.assertTrue(map.containsKey("key4"));
-      Assert.assertEquals("whatever", map.get("key4"));
-   }
-
-   @Test
-   public void testFromCommaSeparatedArrayOfCommaSeparatedKeyValuesForSingleItem() throws Exception
-   {
-      // if there is a single item, no need to enclose it in { }
-      String str = "k11=1, k12=false, k13=2.0, k14=whatever ";
-
-      Object[] objects = ManagementHelper.fromCommaSeparatedArrayOfCommaSeparatedKeyValues(str);
-      Assert.assertEquals(1, objects.length);
-
-      Assert.assertTrue(objects[0] instanceof Map<?, ?>);
-      Map<String, Object> map = (Map<String, Object>) objects[0];
-      Assert.assertEquals(4, map.size());
-      Assert.assertTrue(map.containsKey("k11"));
-      Assert.assertEquals(1L, map.get("k11"));
-
-      Assert.assertTrue(map.containsKey("k12"));
-      Assert.assertEquals(false, map.get("k12"));
-
-      Assert.assertTrue(map.containsKey("k13"));
-      Assert.assertEquals(2.0, map.get("k13"));
-
-      Assert.assertTrue(map.containsKey("k14"));
-      Assert.assertEquals("whatever", map.get("k14"));
-   }
-
-   @Test
-   public void testFromCommaSeparatedArrayOfCommaSeparatedKeyValues() throws Exception
-   {
-      String str = "{ k11=1, k12=false, k13=2.0, k14=whatever },{ k21=2, k22=true, k23=23.0, k24=foo }";
-
-      Object[] objects = ManagementHelper.fromCommaSeparatedArrayOfCommaSeparatedKeyValues(str);
-      Assert.assertEquals(2, objects.length);
-
-      Assert.assertTrue(objects[0] instanceof Map<?, ?>);
-      Map<String, Object> map = (Map<String, Object>) objects[0];
-      Assert.assertEquals(4, map.size());
-      Assert.assertTrue(map.containsKey("k11"));
-      Assert.assertEquals(1L, map.get("k11"));
-
-      Assert.assertTrue(map.containsKey("k12"));
-      Assert.assertEquals(false, map.get("k12"));
-
-      Assert.assertTrue(map.containsKey("k13"));
-      Assert.assertEquals(2.0, map.get("k13"));
-
-      Assert.assertTrue(map.containsKey("k14"));
-      Assert.assertEquals("whatever", map.get("k14"));
-
-      Assert.assertTrue(objects[1] instanceof Map<?, ?>);
-      map = (Map<String, Object>) objects[1];
-      Assert.assertEquals(4, map.size());
-      Assert.assertTrue(map.containsKey("k21"));
-      Assert.assertEquals(2L, map.get("k21"));
-
-      Assert.assertTrue(map.containsKey("k22"));
-      Assert.assertEquals(true, map.get("k22"));
-
-      Assert.assertTrue(map.containsKey("k23"));
-      Assert.assertEquals(23.0, map.get("k23"));
-
-      Assert.assertTrue(map.containsKey("k24"));
-      Assert.assertEquals("foo", map.get("k24"));
-   }
-
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------
diff -Nru hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ManagementWithPagingServerTest.java hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ManagementWithPagingServerTest.java
--- hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ManagementWithPagingServerTest.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/ManagementWithPagingServerTest.java	2016-07-18 12:07:15.442119191 +0200
@@ -13,8 +13,10 @@
 package org.hornetq.tests.integration.management;
 
 import java.nio.ByteBuffer;
+import javax.json.JsonArray;
 
 import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.api.core.SimpleString;
 import org.hornetq.api.core.TransportConfiguration;
 import org.hornetq.api.core.client.ClientConsumer;
@@ -30,7 +32,6 @@
 import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
 import org.hornetq.core.settings.impl.AddressSettings;
 import org.hornetq.tests.util.RandomUtil;
-import org.hornetq.utils.json.JSONArray;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -78,9 +79,9 @@
 
       String result = queueControl.listMessagesAsJSON(null);
 
-      JSONArray array = new JSONArray(result);
+      JsonArray array = JsonUtil.readJsonArray(result);
 
-      assertEquals(num, array.length());
+      assertEquals(num, array.size());
 
       //kick off receiver
       receiver.start();
@@ -90,9 +91,9 @@
 
       result = queueControl.listMessagesAsJSON(null);
 
-      array = new JSONArray(result);
+      array = JsonUtil.readJsonArray(result);
 
-      assertEquals(0, array.length());
+      assertEquals(0, array.size());
    }
 
    @Test
@@ -136,9 +137,9 @@
 
       String jsonString = queueControl.listMessagesAsJSON(filter);
       Assert.assertNotNull(jsonString);
-      JSONArray array = new JSONArray(jsonString);
-      Assert.assertEquals(num / 2, array.length());
-      Assert.assertEquals(matchingValue, array.getJSONObject(0).get("key"));
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(num / 2, array.size());
+      Assert.assertEquals(matchingValue, array.getJsonObject(0).get("key").toString());
 
       long n = queueControl.countMessages(filter);
       assertEquals(num / 2, n);
diff -Nru hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/QueueControlTest.java hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/QueueControlTest.java
--- hornetq-HornetQ_2_4_7_Final/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/QueueControlTest.java	2015-04-13 20:00:17.000000000 +0200
+++ hornetq-HornetQ_2_4_7_Final.javax.json/tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/QueueControlTest.java	2016-07-18 12:15:07.882681164 +0200
@@ -17,9 +17,12 @@
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
+import javax.json.JsonArray;
+import javax.json.JsonObject;
 import javax.management.Notification;
 
 import org.hornetq.api.core.HornetQException;
+import org.hornetq.api.core.JsonUtil;
 import org.hornetq.api.core.Message;
 import org.hornetq.api.core.SimpleString;
 import org.hornetq.api.core.TransportConfiguration;
@@ -46,7 +49,6 @@
 import org.hornetq.core.settings.impl.AddressSettings;
 import org.hornetq.tests.integration.jms.server.management.JMSUtil;
 import org.hornetq.tests.util.RandomUtil;
-import org.hornetq.utils.json.JSONArray;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -230,16 +232,16 @@
 
       System.out.println("Consumers: " + queueControl.listConsumersAsJSON());
 
-      JSONArray obj = new JSONArray(queueControl.listConsumersAsJSON());
+      JsonArray obj = JsonUtil.readJsonArray(queueControl.listConsumersAsJSON());
 
-      assertEquals(1, obj.length());
+      assertEquals(1, obj.size());
 
       consumer.close();
       Assert.assertEquals(0, queueControl.getConsumerCount());
 
-      obj = new JSONArray(queueControl.listConsumersAsJSON());
+      obj = JsonUtil.readJsonArray(queueControl.listConsumersAsJSON());
 
-      assertEquals(0, obj.length());
+      assertEquals(0, obj.size());
 
       session.deleteQueue(queue);
    }
@@ -555,16 +557,16 @@
 
       String jsonString = queueControl.listScheduledMessagesAsJSON();
       Assert.assertNotNull(jsonString);
-      JSONArray array = new JSONArray(jsonString);
-      Assert.assertEquals(1, array.length());
-      Assert.assertEquals(intValue, array.getJSONObject(0).get("key"));
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(1, array.size());
+      Assert.assertEquals(intValue, array.getJsonObject(0).get("key"));
 
       Thread.sleep(delay + 500);
 
       jsonString = queueControl.listScheduledMessagesAsJSON();
       Assert.assertNotNull(jsonString);
-      array = new JSONArray(jsonString);
-      Assert.assertEquals(0, array.length());
+      array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(0, array.size());
 
       ManagementTestBase.consumeMessages(2, session, queue);
 
@@ -615,16 +617,16 @@
 
       String jsonString = queueControl.listMessagesAsJSON(null);
       Assert.assertNotNull(jsonString);
-      JSONArray array = new JSONArray(jsonString);
-      Assert.assertEquals(1, array.length());
-      Assert.assertEquals(intValue, array.getJSONObject(0).get("key"));
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(1, array.size());
+      Assert.assertEquals(intValue, array.getJsonObject(0).get("key"));
 
       ManagementTestBase.consumeMessages(1, session, queue);
 
       jsonString = queueControl.listMessagesAsJSON(null);
       Assert.assertNotNull(jsonString);
-      array = new JSONArray(jsonString);
-      Assert.assertEquals(0, array.length());
+      array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(0, array.size());
 
       session.deleteQueue(queue);
    }
@@ -735,16 +737,16 @@
 
       String jsonString = queueControl.listMessagesAsJSON(filter);
       Assert.assertNotNull(jsonString);
-      JSONArray array = new JSONArray(jsonString);
-      Assert.assertEquals(1, array.length());
-      Assert.assertEquals(matchingValue, array.getJSONObject(0).get("key"));
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(1, array.size());
+      Assert.assertEquals(matchingValue, array.getJsonObject(0).get("key"));
 
       ManagementTestBase.consumeMessages(2, session, queue);
 
       jsonString = queueControl.listMessagesAsJSON(filter);
       Assert.assertNotNull(jsonString);
-      array = new JSONArray(jsonString);
-      Assert.assertEquals(0, array.length());
+      array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(0, array.size());
 
       session.deleteQueue(queue);
    }