use of org.platformlayer.UntypedItemJson in project platformlayer by platformlayer.
the class PlatformLayerCommandRunnerBase method formatRaw.
@Override
public void formatRaw(Object o, PrintWriter writer) {
String data;
if (o instanceof UntypedItemXml) {
UntypedItemXml item = (UntypedItemXml) o;
Source src = new DOMSource(item.getRoot());
String xml = DomUtils.toXml(src, 4);
data = xml;
} else if (o instanceof UntypedItemJson) {
UntypedItemJson item = (UntypedItemJson) o;
JSONObject root = item.getRoot();
try {
data = root.toString(2);
} catch (JSONException e) {
throw new IllegalStateException("Error formatting JSON", e);
}
} else {
super.formatRaw(o, writer);
return;
}
Ansi ansi = new Ansi(writer);
ansi.print(data);
ansi.println();
ansi.reset();
}
Aggregations