Adding JSON format to the CLI. Intents and flows still need to be done.
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/TopologyCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/TopologyCommand.java
index 5c8310f..a7e6422 100644
--- a/cli/src/main/java/org/onlab/onos/cli/net/TopologyCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/net/TopologyCommand.java
@@ -1,5 +1,6 @@
package org.onlab.onos.cli.net;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.karaf.shell.commands.Command;
import org.onlab.onos.cli.AbstractShellCommand;
import org.onlab.onos.net.topology.Topology;
@@ -30,8 +31,17 @@
@Override
protected void execute() {
init();
- print(FMT, topology.time(), topology.deviceCount(), topology.linkCount(),
- topology.clusterCount(), topology.pathCount());
+ if (outputJson()) {
+ print("%s", new ObjectMapper().createObjectNode()
+ .put("time", topology.time())
+ .put("deviceCount", topology.deviceCount())
+ .put("linkCount", topology.linkCount())
+ .put("clusterCount", topology.clusterCount())
+ .put("pathCount", topology.pathCount()));
+ } else {
+ print(FMT, topology.time(), topology.deviceCount(), topology.linkCount(),
+ topology.clusterCount(), topology.pathCount());
+ }
}
}