Methode zum Erstellen des JSON Strings in die GUI Klasse eingefügt

parent 9ae05d55
Pipeline #2948 skipped
......@@ -345,7 +345,7 @@ public class Uebung7GUI1 extends Application {
FileWriter fileWriter = new FileWriter(file);
// TEST STRING!
String content = "GET JSON STRING VOM BACKEND_____";
String content = getJsonString();
fileWriter.write(content);
fileWriter.close();
......@@ -382,8 +382,7 @@ public class Uebung7GUI1 extends Application {
TreeItem<String> item = new TreeItem<>(title);
item.setExpanded(false);
tmpTreeItem.getChildren().add(item);
}
/**
......@@ -399,5 +398,36 @@ public class Uebung7GUI1 extends Application {
makeBranch("ICD-Code: " +icdCode);
}
private static String getJsonString() {
String s = "{\"Diagnosen\":[\n";
for(int i = 0;tree.getTreeItem(i) != null; i++)
{
s = s + "\t{\"Name\":\"" + tree.getTreeItem(i).getValue() + "\", ";
for(int j = 0; j < tree.getTreeItem(i).getChildren().size(); j++)
{
if(tree.getTreeItem(i).getChildren().get(j).getValue().startsWith("ICD-Code"))
{
s = s + "\"ICD-Code\":\""
+ tree.getTreeItem(i).getChildren().get(j).getValue().substring(10)
+ "\"";
}
if(tree.getTreeItem(i).getChildren().get(j).getValue().startsWith("Alpha-ID"))
{
s = s + "\"Alpha-ID\":\""
+ tree.getTreeItem(i).getChildren().get(j).getValue().substring(10)
+ "\", ";
}
}
s= s + "}\n";
}
s = s + "\n]}";
return s;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment