Pretty print the json of the database if it's exported in plain text

pull/41/head
Alexander Bakker 7 years ago
parent db54d38c14
commit fdf8da1f32

@ -14,6 +14,10 @@ public class Database {
private long _counter = 0;
public byte[] serialize() throws Exception {
return serialize(false);
}
public byte[] serialize(boolean pretty) throws Exception {
JSONArray array = new JSONArray();
for (DatabaseEntry e : _entries) {
array.put(e.serialize());
@ -23,7 +27,8 @@ public class Database {
obj.put("version", VERSION);
obj.put("entries", array);
return obj.toString().getBytes("UTF-8");
String string = pretty ? obj.toString(4) : obj.toString();
return string.getBytes("UTF-8");
}
public void deserialize(byte[] data) throws Exception {

@ -111,7 +111,7 @@ public class DatabaseManager {
public String export(boolean encrypt) throws Exception {
assertState(false, true);
byte[] bytes = _db.serialize();
byte[] bytes = _db.serialize(!encrypt);
encrypt = encrypt && getFile().isEncrypted();
if (encrypt) {
CryptResult result = _key.encrypt(bytes);

Loading…
Cancel
Save