Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class JsonArrayIterator extends JsonStructureIterator {

private final Iterator<JsonValue> valueIterator;

private final JsonArray jsonArray;
private JsonValue currentValue;

/**
Expand All @@ -38,6 +38,7 @@ public class JsonArrayIterator extends JsonStructureIterator {
* @param jsonArray json array
*/
public JsonArrayIterator(JsonArray jsonArray) {
this.jsonArray = jsonArray;
this.valueIterator = jsonArray.iterator();
}

Expand All @@ -62,6 +63,9 @@ public JsonParser.Event next() {

@Override
JsonValue getValue() {
if (currentValue == null) {
return jsonArray;
}
return currentValue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,25 @@ public JsonObject getObject() {
if (current instanceof JsonObjectIterator) {
//Remove child iterator as getObject() method contract says
iterators.pop();

return current.getValue().asJsonObject();
} else {
throw new JsonbException(Messages.getMessage(MessageKeys.INTERNAL_ERROR, "Outside of object context"));
}
}

@Override
public JsonArray getArray() {
JsonStructureIterator current = iterators.peek();
if (current instanceof JsonArrayIterator) {
//Remove child iterator as getObject() method contract says
iterators.pop();
return current.getValue().asJsonArray();
} else {
throw new JsonbException(Messages.getMessage(MessageKeys.INTERNAL_ERROR, "Outside of object context"));
}
}

private JsonNumber getJsonNumberValue() {
JsonStructureIterator iterator = iterators.peek();
JsonValue value = iterator.getValue();
Expand Down