support numbers

This commit is contained in:
Peter Hormanns 2013-11-08 16:49:17 +01:00
parent e4157cbfb8
commit 8123764154
2 changed files with 9 additions and 2 deletions

View File

@ -19,6 +19,9 @@ public class JSONFormatter {
if (object instanceof String) {
return formatString((String) object);
}
if (object instanceof Number) {
return formatNumber((Number) object);
}
if (object instanceof Object[]) {
return formatArr((Object[]) object);
}
@ -52,6 +55,10 @@ public class JSONFormatter {
return "'" + str + "'";
}
private String formatNumber(Number num) {
return num.toString();
}
public String formatList(List<?> list) {
return formatArr(list.toArray());
}

View File

@ -34,8 +34,8 @@ public class Main {
}
String expr = cmdParser.getExpression();
if (expr != null && expr.length() > 0) {
scriptClient.execute(expr);
console.println(formatter.format(scriptClient.getLastRpcResult()));
Object execute = scriptClient.execute(expr);
console.println(formatter.format(execute));
}
if (cmdParser.isInteractive()) {
String command = console.readInput();