Skip to content

Commit

Permalink
[Java] Support empty JSON messages. Issue #799.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Jul 2, 2020
1 parent ad76638 commit 0105fa0
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,13 @@ public void onBitSet(
}
}
output.append(" }");

next();
}

public void onBeginComposite(
final Token fieldToken, final List<Token> tokens, final int fromIndex, final int toIndex)
{
++compositeLevel;

property(determineName(1, fieldToken, tokens, fromIndex));
output.append('\n');
startObject();
Expand Down Expand Up @@ -270,11 +268,13 @@ private void appendEncodingAsString(

for (int i = 0; i < arrayLength; i++)
{
if (i > 0)
{
output.append(", ");
}
Types.appendAsJsonString(output, constOrNotPresentValue, encoding);
output.append(", ");
}

backup();
output.append(']');
}
}
Expand Down Expand Up @@ -307,11 +307,13 @@ private void appendEncodingAsString(

for (int i = 0; i < size; i++)
{
if (i > 0)
{
output.append(", ");
}
Types.appendAsJsonString(output, buffer, index + (i * elementSize), encoding);
output.append(", ");
}

backup();
output.append(']');
}
}
Expand All @@ -320,7 +322,11 @@ private void appendEncodingAsString(

private void backup()
{
output.setLength(output.length() - 2);
final int newLength = output.length() - 2;
if (output.charAt(newLength) == ',')
{
output.setLength(newLength);
}
}

private void indent()
Expand Down

0 comments on commit 0105fa0

Please sign in to comment.