in accord-maelstrom/src/main/java/accord/maelstrom/Json.java [208:251]
public void write(JsonWriter out, Txn txn) throws IOException
{
if (txn == null)
{
out.nullValue();
return;
}
Keys keys = (Keys)txn.keys();
MaelstromRead read = (MaelstromRead) txn.read();
MaelstromUpdate update = (MaelstromUpdate) txn.update();
out.beginObject();
out.name("r");
out.beginArray();
for (int i = 0 ; i < keys.size() ; ++i)
{
MaelstromKey.Key key = (MaelstromKey.Key) keys.get(i);
if (read.keys.indexOf(key) >= 0)
{
key.datum.write(out);
}
}
out.endArray();
out.name("append");
out.beginArray();
for (int i = 0 ; i < keys.size() ; ++i)
{
MaelstromKey key = (MaelstromKey) keys.get(i);
if (update != null && update.containsKey(key))
{
out.beginArray();
key.datum.write(out);
update.get(key).write(out);
out.endArray();
}
}
out.endArray();
out.name("client");
out.value(((MaelstromQuery)txn.query()).client.id);
out.name("requestId");
out.value(((MaelstromQuery)txn.query()).requestId);
out.endObject();
}