Add convenience write methods
This commit is contained in:
parent
7f4a0f60fc
commit
f5e2d3405d
|
@ -32,6 +32,8 @@ import java.util.Stack;
|
||||||
import org.hl7.fhir.utilities.TextFile;
|
import org.hl7.fhir.utilities.TextFile;
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonNull;
|
import com.google.gson.JsonNull;
|
||||||
|
@ -619,5 +621,22 @@ public class JsonTrackingParser {
|
||||||
this.errorOnDuplicates = errorOnDuplicates;
|
this.errorOnDuplicates = errorOnDuplicates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void write(JsonObject json, File file) throws IOException {
|
||||||
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
|
String jcnt = gson.toJson(json);
|
||||||
|
TextFile.stringToFile(jcnt, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void write(JsonObject json, String fileName) throws IOException {
|
||||||
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
|
String jcnt = gson.toJson(json);
|
||||||
|
TextFile.stringToFile(jcnt, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String write(JsonObject json) {
|
||||||
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
|
return gson.toJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue