Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Commit

Permalink
Fixed empty array issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
ParkJeongHwan committed Sep 24, 2019
1 parent f573a9a commit aea7667
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
8 changes: 5 additions & 3 deletions src/main/java/com/realtimetech/kson/KsonContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,12 @@ public KsonValue fromString(String kson) throws IOException {
}
} else if (currentMode == ValueMode.ARRAY) {
if (currentChar == ',' || currentChar == ']') {
Object value = valueStack.pop();
if (lastValidChar != '[') {
Object value = valueStack.pop();

KsonArray ksonArray = (KsonArray) valueStack.peek();
ksonArray.add(value);
KsonArray ksonArray = (KsonArray) valueStack.peek();
ksonArray.add(value);
}

if (currentChar == ']') {
modeStack.pop();
Expand Down
25 changes: 16 additions & 9 deletions src/main/java/com/realtimetech/kson/test/TestObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public class TestObject {

private TestEnum enumType1;
private TestEnum enumType2;


private String[] emptyArray;

@Ignore
private byte[] bytes;

Expand Down Expand Up @@ -149,10 +151,11 @@ public TestObject(Test test) {

this.enumType1 = TestEnum.TYPE_1;
this.enumType2 = TestEnum.TYPE_2;

this.intArray = new int[] { 1, 2, 3, 4 };
this.integer = 1;

this.emptyArray = new String[0];
this.stringArray = new String[] { "A", "B", "C" };
this.string = "ABC";

Expand Down Expand Up @@ -258,14 +261,14 @@ public TestObject(Test test) {
this.doubleList.add(1d);
this.doubleList.add(2d);
}

this.testSingleList = new LinkedList<TestSingle>();
{
this.testSingleList.add(new TestSingle());
this.testSingleList.add(new TestSingle());
this.testSingleList.add(new TestSingle());
}

this.mapMap = new HashMap<HashMap<String, String>, HashMap<String, String>>();
{
{
Expand Down Expand Up @@ -301,6 +304,10 @@ public int getInteger() {
return integer;
}

public String[] getEmptyArray() {
return emptyArray;
}

public String[] getStringArray() {
return stringArray;
}
Expand Down Expand Up @@ -380,23 +387,23 @@ public HashMap<HashMap<String, String>, HashMap<String, String>> getMapMap() {
public HashMap<String, String> getStringMap() {
return stringMap;
}

public byte[] getBytes() {
return bytes;
}

public LinkedList<Double> getDoubleLinkedList() {
return doubleLinkedList;
}

public List<Double> getDoubleList() {
return doubleList;
}

public TestEnum getEnumType1() {
return enumType1;
}

public TestEnum getEnumType2() {
return enumType2;
}
Expand Down

0 comments on commit aea7667

Please sign in to comment.