JsonElement e = stack.peekLast();
if (e.isPrimitive()) {
e = stack.pollLast();
JsonElement last = stack.peekLast();
if (last.isObject()) {
JsonObject container = last.asObject();
String key = e.asPrimitive().asString();
container.put(key, value);
} else if (last.isArray()) {
throw new IllegalStateException("shouldn't happen");