Serializing the memo only when the message bytes is not null

develop
Nelson R. Perez 2017-11-27 23:05:42 -05:00
parent de11203ef8
commit 2520099762
1 changed files with 5 additions and 6 deletions

View File

@ -121,20 +121,20 @@ public class TransferOperation extends BaseOperation {
jsonObject.addProperty(KEY_FROM, from.getObjectId());
jsonObject.addProperty(KEY_TO, to.getObjectId());
jsonObject.add(KEY_AMOUNT, amount.toJsonObject());
jsonObject.add(KEY_MEMO, memo.toJsonObject());
if(memo.getByteMessage() != null)
jsonObject.add(KEY_MEMO, memo.toJsonObject());
jsonObject.add(KEY_EXTENSIONS, new JsonArray());
array.add(jsonObject);
return array;
}
/**
* Serializer used to convert this object into a {@link JsonElement} instance
*/
public static class TransferSerializer implements JsonSerializer<TransferOperation> {
@Override
public JsonElement serialize(TransferOperation transfer, Type type, JsonSerializationContext jsonSerializationContext) {
// JsonArray arrayRep = new JsonArray();
// arrayRep.add(transfer.getId());
// arrayRep.add(transfer.toJsonObject());
// return arrayRep;
return transfer.toJsonObject();
}
}
@ -198,7 +198,6 @@ public class TransferOperation extends BaseOperation {
Memo memo = context.deserialize(jsonObject.get(KEY_MEMO), Memo.class);
transfer.setMemo(memo);
}
return transfer;
}
}