// The return value is this object:
JsonObject jsonInventory = new JsonObject();
// These variables are used in loops and repetitive logic.
ItemStack itemStack = null;
JsonElement jsonItemStack = null;
// Every inventory has a content part.
ItemStack[] itemStacks = src.getContents();
if (src instanceof PlayerInventory)