You need to add setCommitNow(true) while building the mutation object and then just do txn.mutate(mutation) and not txn.commit().
Mutation mutation =
Mutation.newBuilder().setSetJson(ByteString.copyFromUtf8(json.toString())).setCommitNow(true).build();
txn.mutate(mutation);
// remove below line
// txn.commit();
That will make it work for now.
This seems like a bug in Dgraph’s ludicrous_mode when commitNow is not given, it fails.
Marking it as a bug.
Thanks for reporting.