[pulsar-admin] Print topic internal info as formatted json
@@ -28,6 +28,8 @@ import com.beust.jcommander.converters.CommaParameterSplitter;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
@@ -599,7 +601,8 @@ public class CmdTopics extends CmdBase {
@Override
void run() throws PulsarAdminException {
String topic = validateTopicName(params);
- String result = getTopics().getInternalInfo(topic);
+ String internalInfo = getTopics().getInternalInfo(topic);
+ JsonObject result = JsonParser.parseString(internalInfo).getAsJsonObject();
Gson gson = new GsonBuilder().setPrettyPrinting().create();
System.out.println(gson.toJson(result));
}
