use of com.bluenimble.platform.json.JsonArray in project serverless by bluenimble.
the class YamlPrinter method printObject.
private void printObject(JsonObject object, int indent, boolean startEndln) throws IOException {
if (Json.isNullOrEmpty(object)) {
return;
}
int counter = 0;
Iterator<String> keys = object.keys();
while (keys.hasNext()) {
String key = keys.next();
if (startEndln || counter > 0) {
endln();
print(key, indent, DataType.Key);
} else {
print(key, 0, DataType.Key);
}
counter++;
print(Colon, DataType.Colon);
Object value = object.get(key);
if (value instanceof JsonObject) {
printObject((JsonObject) value, indent + 1, true);
} else if (value instanceof JsonArray) {
printArray((JsonArray) value, indent + 1);
} else {
String sv = String.valueOf(value);
int indexOfEndLn = sv.indexOf(Lang.ENDLN);
if (indexOfEndLn < 0) {
print(String.valueOf(value), 0, DataType.Value);
} else {
print(Lang.PIPE, 0, DataType.Pipe);
String[] aSv = Lang.split(sv, Lang.ENDLN);
for (String s : aSv) {
endln();
print(s, indent + 1, DataType.Value);
}
}
}
}
}
use of com.bluenimble.platform.json.JsonArray in project serverless by bluenimble.
the class YamlPrinter method printArray.
private void printArray(JsonArray array, int indent) throws IOException {
for (int i = 0; i < array.count(); i++) {
Object value = array.get(i);
endln();
indent(indent);
print(Dash, DataType.Dash);
if (value instanceof JsonObject) {
printObject((JsonObject) value, indent + 1, false);
} else if (value instanceof JsonArray) {
printArray((JsonArray) value, indent);
} else {
print(String.valueOf(value), 0, DataType.Value);
}
}
}
Aggregations