activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/5] activemq-artemis git commit: ARTEMIS-565 Replace json.org with javax.json
Date Tue, 26 Jul 2016 01:46:35 GMT
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java
index 99d742d..d7cced1 100644
--- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java
+++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java
@@ -17,6 +17,11 @@
 package org.apache.activemq.artemis.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.MBeanAttributeInfo;
 import javax.management.MBeanNotificationInfo;
@@ -61,8 +66,6 @@ import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfi
 import org.apache.activemq.artemis.jms.server.management.JMSNotificationType;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.utils.TypedProperties;
-import org.apache.activemq.artemis.utils.json.JSONArray;
-import org.apache.activemq.artemis.utils.json.JSONObject;
 
 public class JMSServerControlImpl extends AbstractControl implements JMSServerControl, NotificationEmitter, org.apache.activemq.artemis.core.server.management.NotificationListener {
 
@@ -599,7 +602,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
       clearIO();
 
       try {
-         JSONArray array = new JSONArray();
+         JsonArrayBuilder array = Json.createArrayBuilder();
 
          Set<RemotingConnection> connections = server.getActiveMQServer().getRemotingService().getConnections();
 
@@ -617,14 +620,15 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
          for (RemotingConnection connection : connections) {
             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());
-               // Notice: this will be null when the user haven't set the client-id
-               obj.put("clientID", session.getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY));
-               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())
+                  // Notice: this will be null when the user haven't set the client-id
+                  .add("clientID", session.getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY))
+                  .add("principal", session.getUsername())
+                  .build();
+               array.add(obj);
             }
          }
          return array.toString();
@@ -641,24 +645,17 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
       clearIO();
 
       try {
-         JSONArray array = new JSONArray();
+         JsonArrayBuilder array = Json.createArrayBuilder();
 
          Set<RemotingConnection> connections = server.getActiveMQServer().getRemotingService().getConnections();
          for (RemotingConnection connection : connections) {
             if (connectionID.equals(connection.getID().toString())) {
                List<ServerSession> sessions = server.getActiveMQServer().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 {
          blockOnIO();
@@ -672,19 +669,8 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
       clearIO();
 
       try {
-         JSONArray array = new JSONArray();
-
-         Set<ServerSession> sessions = server.getActiveMQServer().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.getActiveMQServer().getSessions());
+         return jsonArray.toString();
       }
       finally {
          blockOnIO();
@@ -810,14 +796,14 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
 
       clearIO();
 
-      JSONArray array = new JSONArray();
+      JsonArrayBuilder array = Json.createArrayBuilder();
       try {
          List<ServerSession> sessions = server.getActiveMQServer().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 {
@@ -832,7 +818,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
 
       clearIO();
       try {
-         JSONArray brokers = new JSONArray();
+         JsonArrayBuilder brokers = Json.createArrayBuilder();
          ClusterManager clusterManager = server.getActiveMQServer().getClusterManager();
          if (clusterManager != null) {
             Set<ClusterConnection> clusterConnections = clusterManager.getClusterConnections();
@@ -841,17 +827,17 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
                Collection<TopologyMemberImpl> members = topology.getMembers();
                for (TopologyMemberImpl member : members) {
 
-                  JSONObject obj = new JSONObject();
+                  JsonObjectBuilder obj = Json.createObjectBuilder();
                   TransportConfiguration live = member.getLive();
                   if (live != null) {
-                     obj.put("nodeID", member.getNodeId());
-                     obj.put("live", live.getParams().get("host") + ":" + live.getParams().get("port"));
+                     obj.add("nodeID", member.getNodeId())
+                        .add("live", live.getParams().get("host") + ":" + live.getParams().get("port"));
                      TransportConfiguration backup = member.getBackup();
                      if (backup != null) {
-                        obj.put("backup", backup.getParams().get("host") + ":" + backup.getParams().get("port"));
+                        obj.add("backup", backup.getParams().get("host") + ":" + backup.getParams().get("port"));
                      }
                   }
-                  brokers.put(obj);
+                  brokers.add(obj);
                }
             }
          }
@@ -867,39 +853,41 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
       return server.getActiveMQServer().destroyConnectionWithSessionMetadata(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY, 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]);
+      // JMS consumer with message filter use the queue's filter
+      Filter queueFilter = consumer.getQueue().getFilter();
+      if (queueFilter != null) {
+         obj.add("filter", queueFilter.getFilterString().toString());
+      }
+
+
       if (destinationInfo[1].equals("topic")) {
          try {
             ActiveMQDestination.decomposeQueueNameForDurableSubscription(consumer.getQueue().getName().toString());
-            obj.put("durable", true);
+            obj.add("durable", true);
          }
          catch (IllegalArgumentException | 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
@@ -912,4 +900,19 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
       this.broadcaster.sendNotification(new Notification(type.toString(), this, 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();
+   }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSTopicControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSTopicControlImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSTopicControlImpl.java
index 5a0842d..5de407d 100644
--- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSTopicControlImpl.java
+++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSTopicControlImpl.java
@@ -21,6 +21,9 @@ import java.util.Collections;
 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;
 
@@ -37,8 +40,8 @@ import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
 import org.apache.activemq.artemis.jms.client.ActiveMQMessage;
 import org.apache.activemq.artemis.jms.server.JMSServerManager;
 import org.apache.activemq.artemis.utils.SelectorTranslator;
-import org.apache.activemq.artemis.utils.json.JSONArray;
-import org.apache.activemq.artemis.utils.json.JSONObject;
+
+import static org.apache.activemq.artemis.api.core.JsonUtil.nullSafe;
 
 public class JMSTopicControlImpl extends StandardMBean implements TopicControl {
 
@@ -289,7 +292,7 @@ public class JMSTopicControlImpl extends StandardMBean implements TopicControl {
    private String listSubscribersInfosAsJSON(final DurabilityType durability) throws Exception {
       try {
          List<QueueControl> queues = getQueues(durability);
-         JSONArray array = new JSONArray();
+         JsonArrayBuilder array = Json.createArrayBuilder();
 
          for (QueueControl queue : queues) {
             String clientID = null;
@@ -310,20 +313,21 @@ public class JMSTopicControlImpl extends StandardMBean implements TopicControl {
 
             String filter = queue.getFilter() != null ? queue.getFilter() : null;
 
-            JSONObject info = new JSONObject();
-
-            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);
+            JsonObject info = Json.createObjectBuilder()
+               .add("queueName", queue.getName())
+               .add("clientID", nullSafe(clientID))
+               .add("selector", nullSafe(filter))
+               .add("name", nullSafe(subName))
+               .add("durable", queue.isDurable())
+               .add("messageCount", queue.getMessageCount())
+               .add("deliveringCount", queue.getDeliveringCount())
+               .add("consumers", queue.listConsumersAsJSON())
+               .build();
+
+            array.add(info);
          }
 
-         return array.toString();
+         return array.build().toString();
       }
       catch (Exception e) {
          e.printStackTrace();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java
index 228c1bd..194c598 100644
--- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java
+++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java
@@ -16,6 +16,10 @@
  */
 package org.apache.activemq.artemis.jms.server.impl;
 
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
 import javax.naming.NamingException;
 import javax.transaction.xa.Xid;
 import java.net.InetAddress;
@@ -87,8 +91,6 @@ import org.apache.activemq.artemis.spi.core.naming.BindingRegistry;
 import org.apache.activemq.artemis.utils.SelectorTranslator;
 import org.apache.activemq.artemis.utils.TimeAndCounterIDGenerator;
 import org.apache.activemq.artemis.utils.TypedProperties;
-import org.apache.activemq.artemis.utils.json.JSONArray;
-import org.apache.activemq.artemis.utils.json.JSONObject;
 
 /**
  * A Deployer used to create and add to Bindings queues, topics and connection
@@ -1343,7 +1345,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
          }
       });
 
-      JSONArray txDetailListJson = new JSONArray();
+      JsonArrayBuilder txDetailListJson = Json.createArrayBuilder();
       for (Map.Entry<Xid, Long> entry : xidsSortedByCreationTime) {
          Xid xid = entry.getKey();
          Transaction tx = resourceManager.getTransaction(xid);
@@ -1351,7 +1353,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
             continue;
          }
          TransactionDetail detail = new JMSTransactionDetail(xid, tx, entry.getValue());
-         txDetailListJson.put(detail.toJSON());
+         txDetailListJson.add(detail.toJSON());
       }
       return txDetailListJson.toString();
    }
@@ -1383,7 +1385,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
             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>");
@@ -1401,14 +1403,13 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
          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();
-            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));

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/artemis-server/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java b/artemis-server/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java
index dba80b6..bbad79b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java
@@ -19,8 +19,13 @@ package org.apache.activemq.artemis.api.core.management;
 import java.text.DateFormat;
 import java.util.Date;
 
+import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.core.messagecounter.MessageCounter;
-import org.apache.activemq.artemis.utils.json.JSONObject;
+
+import javax.json.Json;
+import javax.json.JsonObject;
+
+import static org.apache.activemq.artemis.api.core.JsonUtil.nullSafe;
 
 /**
  * Helper class to create Java Objects from the
@@ -55,27 +60,33 @@ public final class MessageCounterInfo {
     */
    public static String toJSon(final MessageCounter counter) throws Exception {
       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", nullSafe(counter.getDestinationName()))
+         .add("destinationSubscription", nullSafe(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");
+      String subscription = data.getString("destinationSubscription", null);
       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");

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
index 9b5ec20..e7c26aa 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
@@ -22,14 +22,17 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 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.MBeanAttributeInfo;
 import javax.management.MBeanNotificationInfo;
@@ -88,8 +91,6 @@ import org.apache.activemq.artemis.core.transaction.impl.XidImpl;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.utils.SecurityFormatter;
 import org.apache.activemq.artemis.utils.TypedProperties;
-import org.apache.activemq.artemis.utils.json.JSONArray;
-import org.apache.activemq.artemis.utils.json.JSONObject;
 
 public class ActiveMQServerControlImpl extends AbstractControl implements ActiveMQServerControl, NotificationEmitter, org.apache.activemq.artemis.core.server.management.NotificationListener {
    // Constants -----------------------------------------------------
@@ -974,7 +975,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
             }
          });
 
-         JSONArray txDetailListJson = new JSONArray();
+         JsonArrayBuilder txDetailListJson = Json.createArrayBuilder();
          for (Map.Entry<Xid, Long> entry : xidsSortedByCreationTime) {
             Xid xid = entry.getKey();
 
@@ -986,9 +987,9 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
 
             TransactionDetail detail = new CoreTransactionDetail(xid, tx, entry.getValue());
 
-            txDetailListJson.put(detail.toJSON());
+            txDetailListJson.add(detail.toJSON());
          }
-         return txDetailListJson.toString();
+         return txDetailListJson.build().toString();
       }
       finally {
          blockOnIO();
@@ -1029,7 +1030,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
 
             TransactionDetail detail = new CoreTransactionDetail(xid, tx, entry.getValue());
 
-            JSONObject txJson = detail.toJSON();
+            JsonObject txJson = detail.toJSON();
 
             html.append("<table border=\"1\">");
             html.append("<tr><th>creation_time</th>");
@@ -1047,14 +1048,13 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
             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();
-               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));
@@ -1350,13 +1350,13 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
    */
    @Override
    public String listProducersInfoAsJSON() throws Exception {
-      JSONArray producers = new JSONArray();
+      JsonArrayBuilder producers = Json.createArrayBuilder();
 
       for (ServerSession session : server.getSessions()) {
          session.describeProducersInfo(producers);
       }
 
-      return producers.toString();
+      return producers.build().toString();
    }
 
    @Override
@@ -1393,13 +1393,13 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
 
       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 {
          blockOnIO();
@@ -1488,13 +1488,13 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
 
       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();
+         return json.build().toString();
       }
       finally {
          blockOnIO();
@@ -1506,37 +1506,36 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
       checkStarted();
 
       AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch(address);
-      Map<String, Object> settings = new HashMap<>();
+      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.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);
-      settings.put("autoCreateJmsQueues", addressSettings.isAutoCreateJmsQueues());
-      settings.put("autoDeleteJmsQueues", addressSettings.isAutoDeleteJmsQueues());
-      settings.put("autoCreateJmsTopics", addressSettings.isAutoCreateJmsTopics());
-      settings.put("autoDeleteJmsTopics", addressSettings.isAutoDeleteJmsTopics());
-
-      JSONObject jsonObject = new JSONObject(settings);
-      return jsonObject.toString();
+         settings.add("expiryAddress", addressSettings.getExpiryAddress().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)
+         .add("autoCreateJmsQueues", addressSettings.isAutoCreateJmsQueues())
+         .add("autoDeleteJmsQueues", addressSettings.isAutoDeleteJmsQueues())
+         .add("autoCreateJmsTopics", addressSettings.isAutoCreateJmsTopics())
+         .add("autoDeleteJmsTopics", addressSettings.isAutoDeleteJmsTopics())
+         .build().toString();
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
index 7cb67af..9ea4081 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.artemis.core.management.impl;
 
+import javax.json.Json;
+import javax.json.JsonArrayBuilder;
 import javax.management.MBeanAttributeInfo;
 import javax.management.MBeanOperationInfo;
 import java.util.ArrayList;
@@ -34,8 +36,6 @@ import org.apache.activemq.artemis.core.postoffice.QueueBinding;
 import org.apache.activemq.artemis.core.security.CheckType;
 import org.apache.activemq.artemis.core.security.Role;
 import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
-import org.apache.activemq.artemis.utils.json.JSONArray;
-import org.apache.activemq.artemis.utils.json.JSONObject;
 
 public class AddressControlImpl extends AbstractControl implements AddressControl {
 
@@ -140,11 +140,11 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
    public String getRolesAsJSON() throws Exception {
       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();
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BroadcastGroupControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BroadcastGroupControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BroadcastGroupControlImpl.java
index d6ef25e..7b206e8 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BroadcastGroupControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BroadcastGroupControlImpl.java
@@ -22,9 +22,9 @@ import javax.management.MBeanOperationInfo;
 import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration;
 import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory;
 import org.apache.activemq.artemis.api.core.management.BroadcastGroupControl;
+import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
-import org.apache.activemq.artemis.utils.json.JSONArray;
 
 public class BroadcastGroupControlImpl extends AbstractControl implements BroadcastGroupControl {
 
@@ -94,12 +94,7 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
    public String getConnectorPairsAsJSON() throws Exception {
       clearIO();
       try {
-         JSONArray array = new JSONArray();
-
-         for (String connector : configuration.getConnectorInfos()) {
-            array.put(connector);
-         }
-         return array.toString();
+         return JsonUtil.toJsonArray(configuration.getConnectorInfos()).toString();
       }
       finally {
          blockOnIO();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ClusterConnectionControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ClusterConnectionControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ClusterConnectionControlImpl.java
index 17426d0..f374c3f 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ClusterConnectionControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ClusterConnectionControlImpl.java
@@ -22,10 +22,10 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.activemq.artemis.api.core.management.ClusterConnectionControl;
+import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
 import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
-import org.apache.activemq.artemis.utils.json.JSONArray;
 
 public class ClusterConnectionControlImpl extends AbstractControl implements ClusterConnectionControl {
 
@@ -143,18 +143,7 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
    public String getStaticConnectorsAsJSON() throws Exception {
       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 {
          blockOnIO();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
index a375cb3..de2459f 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
@@ -16,6 +16,10 @@
  */
 package org.apache.activemq.artemis.core.management.impl;
 
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObjectBuilder;
 import javax.management.MBeanAttributeInfo;
 import javax.management.MBeanOperationInfo;
 import javax.management.openmbean.CompositeData;
@@ -27,6 +31,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.management.MessageCounterInfo;
@@ -55,9 +60,6 @@ import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.utils.Base64;
 import org.apache.activemq.artemis.utils.LinkedListIterator;
 import org.apache.activemq.artemis.utils.UUID;
-import org.apache.activemq.artemis.utils.json.JSONArray;
-import org.apache.activemq.artemis.utils.json.JSONException;
-import org.apache.activemq.artemis.utils.json.JSONObject;
 
 public class QueueControlImpl extends AbstractControl implements QueueControl {
 
@@ -81,33 +83,28 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
    // Static --------------------------------------------------------
 
    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();
    }
 
    // Constructors --------------------------------------------------
@@ -950,26 +947,26 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
       try {
          Collection<Consumer> consumers = queue.getConsumers();
 
-         JSONArray jsonArray = new JSONArray();
+         JsonArrayBuilder jsonArray = Json.createArrayBuilder();
 
          for (Consumer consumer : consumers) {
 
             if (consumer instanceof ServerConsumer) {
                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);
             }
 
          }
 
-         return jsonArray.toString();
+         return jsonArray.build().toString();
       }
       finally {
          blockOnIO();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java
index 7378b5a..2b90cbc 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.core.server;
 
+import javax.json.JsonArrayBuilder;
 import javax.transaction.xa.Xid;
 import java.util.List;
 import java.util.Set;
@@ -27,7 +28,6 @@ import org.apache.activemq.artemis.core.postoffice.RoutingStatus;
 import org.apache.activemq.artemis.core.security.SecurityAuth;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
-import org.apache.activemq.artemis.utils.json.JSONArray;
 
 public interface ServerSession extends SecurityAuth {
 
@@ -166,7 +166,7 @@ public interface ServerSession extends SecurityAuth {
     * @param objs
     * @throws Exception
     */
-   void describeProducersInfo(JSONArray objs) throws Exception;
+   void describeProducersInfo(JsonArrayBuilder objs) throws Exception;
 
    String getLastSentMessageID(String address);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
index e4ad9b4..79154f7 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
@@ -16,6 +16,9 @@
  */
 package org.apache.activemq.artemis.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;
@@ -83,10 +86,10 @@ import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
 import org.apache.activemq.artemis.utils.TypedProperties;
 import org.apache.activemq.artemis.utils.UUID;
-import org.apache.activemq.artemis.utils.json.JSONArray;
-import org.apache.activemq.artemis.utils.json.JSONObject;
 import org.jboss.logging.Logger;
 
+import static org.apache.activemq.artemis.api.core.JsonUtil.nullSafe;
+
 /**
  * Server side Session implementation
  */
@@ -1402,17 +1405,21 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
    }
 
    @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);
+         String uuid = null;
+         if (entry.getValue().getA() != null) {
+            uuid = entry.getValue().getA().toString();
+         }
+         JsonObjectBuilder producerInfo = Json.createObjectBuilder()
+            .add("connectionID", this.getConnectionID().toString())
+            .add("sessionID", this.getName())
+            .add("destination", entry.getKey().toString())
+            .add("lastUUIDSent", nullSafe(uuid))
+            .add("msgSent", entry.getValue().getB().longValue());
+         array.add(producerInfo);
       }
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java
index 068b15f..01b39dc 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java
@@ -21,13 +21,16 @@ import java.util.Date;
 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.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.transaction.impl.XidImpl;
-import org.apache.activemq.artemis.utils.json.JSONArray;
-import org.apache.activemq.artemis.utils.json.JSONObject;
 
 public abstract class TransactionDetail {
 
@@ -61,27 +64,24 @@ public abstract class TransactionDetail {
       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();
+      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()));
 
-      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()));
-
-      JSONArray msgsJson = new JSONArray();
+      JsonArrayBuilder msgsJson = Json.createArrayBuilder();
 
       List<TransactionOperation> txops = null;
 
       if (this.transaction != null) {
          txops = this.transaction.getAllOperations();
       }
-
-      detailJson.put(KEY_TX_RELATED_MESSAGES, msgsJson);
       if (txops == null) {
-         return detailJson;
+         return detailJson.build();
       }
 
       for (TransactionOperation op : txops) {
@@ -100,18 +100,19 @@ public abstract class TransactionDetail {
          }
 
          for (MessageReference ref : msgs) {
-            JSONObject msgJson = new JSONObject();
-            msgsJson.put(msgJson);
+            JsonObjectBuilder msgJson = Json.createObjectBuilder();
 
-            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);
+            msgsJson.add(msgJson);
          }
       }
-      return detailJson;
+      detailJson.add(KEY_TX_RELATED_MESSAGES, msgsJson);
+      return detailJson.build();
    }
 
    public abstract String decodeMessageType(ServerMessage msg);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 20f78bb..4456c65 100644
--- a/pom.xml
+++ b/pom.xml
@@ -84,6 +84,8 @@
       <resteasy.version>3.0.17.Final</resteasy.version>
       <slf4j.version>1.7.12</slf4j.version>
       <qpid.jms.version>0.9.0</qpid.jms.version>
+      <johnzon.version>0.9.4</johnzon.version>
+      <json-p.spec.version>1.0-alpha-1</json-p.spec.version>
 
       <activemq.version.versionName>${project.version}</activemq.version.versionName>
       <activemq.version.majorVersion>1</activemq.version.majorVersion>
@@ -91,9 +93,7 @@
       <activemq.version.microVersion>0</activemq.version.microVersion>
       <activemq.version.incrementingVersion>127,126,125,124,123,122</activemq.version.incrementingVersion>
       <activemq.version.versionTag>${project.version}</activemq.version.versionTag>
-      <ActiveMQ-Version>
-         ${project.version}(${activemq.version.incrementingVersion})
-      </ActiveMQ-Version>
+      <ActiveMQ-Version>${project.version}(${activemq.version.incrementingVersion})</ActiveMQ-Version>
 
       <skipUnitTests>true</skipUnitTests>
       <skipJmsTests>true</skipJmsTests>
@@ -436,6 +436,17 @@
            <version>${slf4j.version}</version>
            <!-- License: MIT -->
          </dependency>
+         <!-- json -->
+         <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-json_1.0_spec</artifactId>
+            <version>${json-p.spec.version}</version>
+         </dependency>
+         <dependency>
+            <groupId>org.apache.johnzon</groupId>
+            <artifactId>johnzon-core</artifactId>
+            <version>${johnzon.version}</version>
+         </dependency>
 
          <!--needed for the rest support-->
          <dependency>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/tests/integration-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/pom.xml b/tests/integration-tests/pom.xml
index 5d7617c..3622eb1 100644
--- a/tests/integration-tests/pom.xml
+++ b/tests/integration-tests/pom.xml
@@ -73,6 +73,16 @@
          <version>${project.version}</version>
       </dependency>
       <dependency>
+         <groupId>org.apache.geronimo.specs</groupId>
+         <artifactId>geronimo-json_1.0_spec</artifactId>
+         <scope>test</scope>
+      </dependency>
+      <dependency>
+         <groupId>org.apache.johnzon</groupId>
+         <artifactId>johnzon-core</artifactId>
+         <scope>test</scope>
+      </dependency>
+      <dependency>
          <groupId>org.apache.activemq</groupId>
          <artifactId>artemis-jms-server</artifactId>
          <version>${project.version}</version>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java
index ded85ec..7babcfc 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/aerogear/AeroGearBasicServerTest.java
@@ -24,6 +24,7 @@ import org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
 import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
+import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.core.config.Configuration;
 import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration;
 import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
@@ -31,9 +32,6 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.integration.aerogear.AeroGearConnectorServiceFactory;
 import org.apache.activemq.artemis.integration.aerogear.AeroGearConstants;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
-import org.apache.activemq.artemis.utils.json.JSONArray;
-import org.apache.activemq.artemis.utils.json.JSONException;
-import org.apache.activemq.artemis.utils.json.JSONObject;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -42,6 +40,8 @@ import org.mortbay.jetty.Server;
 import org.mortbay.jetty.handler.AbstractHandler;
 import org.mortbay.jetty.nio.SelectChannelConnector;
 
+import javax.json.JsonArray;
+import javax.json.JsonObject;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -118,7 +118,7 @@ public class AeroGearBasicServerTest extends ActiveMQTestBase {
 
       assertTrue(latch.await(5, TimeUnit.SECONDS));
       assertNotNull(aeroGearHandler.jsonObject);
-      JSONObject body = (JSONObject) aeroGearHandler.jsonObject.get("message");
+      JsonObject body = aeroGearHandler.jsonObject.getJsonObject("message");
       assertNotNull(body);
       String prop1 = body.getString("AEROGEAR_PROP1");
       assertNotNull(prop1);
@@ -132,25 +132,24 @@ public class AeroGearBasicServerTest extends ActiveMQTestBase {
       String sound = body.getString("sound");
       assertNotNull(sound);
       assertEquals(sound, "sound1");
-      String badge = body.getString("badge");
+      int badge = body.getInt("badge");
       assertNotNull(badge);
-      assertEquals(badge, "99");
-      JSONArray jsonArray = (JSONArray) aeroGearHandler.jsonObject.get("variants");
+      assertEquals(badge, 99);
+      JsonArray jsonArray = aeroGearHandler.jsonObject.getJsonArray("variants");
       assertNotNull(jsonArray);
       assertEquals(jsonArray.getString(0), "variant1");
       assertEquals(jsonArray.getString(1), "variant2");
-      jsonArray = (JSONArray) aeroGearHandler.jsonObject.get("alias");
+      jsonArray = aeroGearHandler.jsonObject.getJsonArray("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 = aeroGearHandler.jsonObject.getJsonArray("deviceType");
       assertNotNull(jsonArray);
       assertEquals(jsonArray.getString(0), "android");
       assertEquals(jsonArray.getString(1), "ipad");
-      Integer ttl = (Integer) aeroGearHandler.jsonObject.get("ttl");
-      assertNotNull(ttl);
-      assertEquals(ttl.intValue(), 3600);
+      int ttl = aeroGearHandler.jsonObject.getInt("ttl");
+      assertEquals(ttl, 3600);
       latch = new CountDownLatch(1);
       aeroGearHandler.resetLatch(latch);
 
@@ -167,7 +166,7 @@ public class AeroGearBasicServerTest extends ActiveMQTestBase {
       producer.send(m);
       assertTrue(latch.await(5, TimeUnit.SECONDS));
       assertNotNull(aeroGearHandler.jsonObject);
-      body = (JSONObject) aeroGearHandler.jsonObject.get("message");
+      body = aeroGearHandler.jsonObject.getJsonObject("message");
       assertNotNull(body);
       alert = body.getString("alert");
       assertNotNull(alert);
@@ -175,24 +174,22 @@ public class AeroGearBasicServerTest extends ActiveMQTestBase {
       sound = body.getString("sound");
       assertNotNull(sound);
       assertEquals(sound, "s1");
-      badge = body.getString("badge");
-      assertNotNull(badge);
-      assertEquals(badge, "111");
-      jsonArray = (JSONArray) aeroGearHandler.jsonObject.get("variants");
+      badge = body.getInt("badge");
+      assertEquals(badge, 111);
+      jsonArray = aeroGearHandler.jsonObject.getJsonArray("variants");
       assertNotNull(jsonArray);
       assertEquals(jsonArray.getString(0), "v1");
       assertEquals(jsonArray.getString(1), "v2");
-      jsonArray = (JSONArray) aeroGearHandler.jsonObject.get("alias");
+      jsonArray = aeroGearHandler.jsonObject.getJsonArray("alias");
       assertNotNull(jsonArray);
       assertEquals(jsonArray.getString(0), "alias1");
       assertEquals(jsonArray.getString(1), "alias2");
-      jsonArray = (JSONArray) aeroGearHandler.jsonObject.get("deviceType");
+      jsonArray = aeroGearHandler.jsonObject.getJsonArray("deviceType");
       assertNotNull(jsonArray);
       assertEquals(jsonArray.getString(0), "dev1");
       assertEquals(jsonArray.getString(1), "dev2");
-      ttl = (Integer) aeroGearHandler.jsonObject.get("ttl");
-      assertNotNull(ttl);
-      assertEquals(ttl.intValue(), 10000);
+      ttl = aeroGearHandler.jsonObject.getInt("ttl");
+      assertEquals(ttl, 10000);
       session.start();
       ClientMessage message = session.createConsumer("testQueue").receiveImmediate();
       assertNull(message);
@@ -200,7 +197,7 @@ public class AeroGearBasicServerTest extends ActiveMQTestBase {
 
    class AeroGearHandler extends AbstractHandler {
 
-      JSONObject jsonObject;
+      JsonObject jsonObject;
       private CountDownLatch latch;
 
       AeroGearHandler(CountDownLatch latch) {
@@ -219,12 +216,7 @@ public class AeroGearBasicServerTest extends ActiveMQTestBase {
          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();
       }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java
index 90aa8f9..406dc8f 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSQueueControlTest.java
@@ -43,6 +43,7 @@ import org.apache.activemq.artemis.api.core.client.ClientProducer;
 import org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
+import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
 import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
 import org.apache.activemq.artemis.api.jms.JMSFactoryType;
@@ -68,10 +69,10 @@ import org.apache.activemq.artemis.tests.integration.management.ManagementTestBa
 import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
 import org.apache.activemq.artemis.utils.RandomUtil;
 import org.apache.activemq.artemis.utils.UUIDGenerator;
-import org.apache.activemq.artemis.utils.json.JSONArray;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import javax.json.JsonArray;
 
 /**
  * A QueueControlTest
@@ -111,9 +112,9 @@ public class JMSQueueControlTest extends ManagementTestBase {
 
       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);
 
@@ -433,17 +434,17 @@ public class JMSQueueControlTest extends ManagementTestBase {
 
       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).getString("JMSMessageID"));
+      Assert.assertEquals(ids[1], array.getJsonObject(1).getString("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

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java
index 11546fc..41bfc70 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlTest.java
@@ -22,6 +22,7 @@ import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
 import org.apache.activemq.artemis.api.core.management.AddressControl;
+import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
 import org.apache.activemq.artemis.api.core.management.ResourceNames;
 import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
@@ -48,7 +49,6 @@ import org.apache.activemq.artemis.tests.integration.management.ManagementTestBa
 import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
 import org.apache.activemq.artemis.utils.RandomUtil;
-import org.apache.activemq.artemis.utils.json.JSONArray;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -66,6 +66,7 @@ import javax.jms.Topic;
 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;
@@ -627,15 +628,15 @@ public class JMSServerControlTest extends ManagementTestBase {
       // 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());
 
-      Assert.assertEquals(1 + getNumberOfConsumers(), jsonArray.length());
+      Assert.assertEquals(1 + getNumberOfConsumers(), jsonArray.size());
 
       cons.close();
 
-      jsonArray = new JSONArray(control.listAllConsumersAsJSON());
+      jsonArray = JsonUtil.readJsonArray(control.listAllConsumersAsJSON());
 
-      Assert.assertEquals(getNumberOfConsumers(), jsonArray.length());
+      Assert.assertEquals(getNumberOfConsumers(), jsonArray.size());
 
       String topicAddress = ActiveMQDestination.createTopicAddressFromName(topicName).toString();
       AddressControl addressControl = (AddressControl) server.getManagementService().getResource(ResourceNames.CORE_ADDRESS + topicAddress);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlTest.java
index 238aaa0..25fd608 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/TopicControlTest.java
@@ -17,6 +17,7 @@
 package org.apache.activemq.artemis.tests.integration.jms.server.management;
 
 import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
+import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
 import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
 import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
@@ -37,7 +38,6 @@ import org.apache.activemq.artemis.tests.integration.management.ManagementContro
 import org.apache.activemq.artemis.tests.integration.management.ManagementTestBase;
 import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
 import org.apache.activemq.artemis.utils.RandomUtil;
-import org.apache.activemq.artemis.utils.json.JSONArray;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -51,6 +51,7 @@ import javax.jms.MessageProducer;
 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.Arrays;
@@ -159,9 +160,9 @@ public class TopicControlTest extends ManagementTestBase {
 
       String json = topicControl.listAllSubscriptionsAsJSON();
       System.out.println("Json: " + json);
-      JSONArray jsonArray = new JSONArray(json);
+      JsonArray jsonArray = JsonUtil.readJsonArray(json);
 
-      Assert.assertEquals(3, jsonArray.length());
+      Assert.assertEquals(3, jsonArray.size());
 
       connection_1.close();
       connection_2.close();
@@ -221,17 +222,17 @@ public class TopicControlTest extends ManagementTestBase {
       SubscriptionInfo[] infos = SubscriptionInfo.from(jsonString);
       Assert.assertEquals(2, infos.length);
 
-      Assert.assertTrue(infos[0].getClientID().length() == 0);
+      Assert.assertNull(infos[0].getClientID());
       Assert.assertTrue(infos[0].getName().equals(subscriptionName));
 
-      Assert.assertTrue(infos[1].getClientID().length() == 0);
+      Assert.assertNull(infos[1].getClientID());
       Assert.assertTrue(infos[1].getName().equals(subscriptionName + "2"));
 
       jsonString = topicControl.listNonDurableSubscriptionsAsJSON();
       infos = SubscriptionInfo.from(jsonString);
       Assert.assertEquals(1, infos.length);
-      Assert.assertEquals(null, infos[0].getClientID());
-      Assert.assertEquals(null, infos[0].getName());
+      Assert.assertNull(infos[0].getClientID());
+      Assert.assertNull(infos[0].getName());
 
       jsonString = topicControl.listAllSubscriptionsAsJSON();
       infos = SubscriptionInfo.from(jsonString);
@@ -442,10 +443,10 @@ public class TopicControlTest extends ManagementTestBase {
       TopicControl topicControl = createManagementControl();
       String jsonString = topicControl.listMessagesForSubscriptionAsJSON(ActiveMQDestination.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).getString("JMSMessageID"));
       }
 
       connection.close();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
index 2d4d983..7de651d 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.artemis.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;
@@ -33,6 +35,7 @@ import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
 import org.apache.activemq.artemis.api.core.management.AddressSettingsInfo;
 import org.apache.activemq.artemis.api.core.management.BridgeControl;
 import org.apache.activemq.artemis.api.core.management.DivertControl;
+import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
 import org.apache.activemq.artemis.api.core.management.QueueControl;
 import org.apache.activemq.artemis.api.core.management.RoleInfo;
@@ -47,8 +50,6 @@ import org.apache.activemq.artemis.core.transaction.impl.XidImpl;
 import org.apache.activemq.artemis.jlibaio.LibaioContext;
 import org.apache.activemq.artemis.utils.RandomUtil;
 import org.apache.activemq.artemis.utils.UUIDGenerator;
-import org.apache.activemq.artemis.utils.json.JSONArray;
-import org.apache.activemq.artemis.utils.json.JSONObject;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -154,12 +155,12 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
 
       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
@@ -755,10 +756,10 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
 
       ActiveMQServerControl 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();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java
index 0298eb4..ce8873f 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java
@@ -20,15 +20,16 @@ import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory;
 import org.apache.activemq.artemis.api.core.management.BroadcastGroupControl;
+import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.core.config.Configuration;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServers;
 import org.apache.activemq.artemis.utils.RandomUtil;
-import org.apache.activemq.artemis.utils.json.JSONArray;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import javax.json.JsonArray;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -54,8 +55,8 @@ public class BroadcastGroupControlTest extends ManagementTestBase {
       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());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlTest.java
index 98b9bed..f2b85ec 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.tests.integration.management;
 
+import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
 import org.junit.Before;
 import org.junit.After;
@@ -26,6 +27,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.json.JsonArray;
 import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;
 
@@ -48,7 +50,6 @@ import org.apache.activemq.artemis.core.server.ActiveMQServers;
 import org.apache.activemq.artemis.core.server.management.Notification;
 import org.apache.activemq.artemis.tests.integration.SimpleNotificationService;
 import org.apache.activemq.artemis.utils.RandomUtil;
-import org.apache.activemq.artemis.utils.json.JSONArray;
 
 public class ClusterConnectionControlTest extends ManagementTestBase {
 
@@ -91,8 +92,8 @@ public class ClusterConnectionControlTest extends ManagementTestBase {
 
       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());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementHelperTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementHelperTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementHelperTest.java
index bf72cc6..9fb95e7 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementHelperTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementHelperTest.java
@@ -227,87 +227,6 @@ public class ManagementHelperTest extends Assert {
 
    }
 
-   @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 -----------------------------------------------------


Mime
View raw message