Skip to content
Open
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
25 changes: 8 additions & 17 deletions src/main/java/com/alibaba/fastjson/JSONReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,15 @@ public void startObject() {
context = new JSONStreamContext(null, JSONStreamContext.StartObject);
} else {
startStructure();
if (lastContext != null
&& lastContext.parent == context) {
if(lastContext == null){
context = new JSONStreamContext(context, JSONStreamContext.StartObject);
}else if(lastContext.parent == context){
context = lastContext;
if (context.state != JSONStreamContext.StartObject) {
context.state = JSONStreamContext.StartObject;
}
} else {
context = new JSONStreamContext(context, JSONStreamContext.StartObject);
}
}

this.parser.accept(JSONToken.LBRACE, JSONToken.IDENTIFIER);
}

Expand All @@ -90,13 +88,10 @@ public void endObject() {
}

public void startArray() {
if (context == null) {
context = new JSONStreamContext(null, StartArray);
} else {
if (context != null) {
startStructure();

context = new JSONStreamContext(context, StartArray);
}
context = new JSONStreamContext(context, StartArray);
this.parser.accept(JSONToken.LBRACKET);
}

Expand Down Expand Up @@ -132,24 +127,20 @@ private void endStructure() {
}

final int state = context.state;
int newState = -1;
switch (state) {
case PropertyKey:
newState = PropertyValue;
context.state = PropertyValue;
break;
case StartArray:
newState = ArrayValue;
context.state = ArrayValue;
break;
case PropertyValue:
case StartObject:
newState = PropertyKey;
context.state = PropertyKey;
break;
default:
break;
}
if (newState != -1) {
context.state = newState;
}
}

public boolean hasNext() {
Expand Down