Skip to content

[Java] JsonPrinter does not handle empty groups #800

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Audrius-GR opened this issue Jul 8, 2020 · 2 comments
Closed

[Java] JsonPrinter does not handle empty groups #800

Audrius-GR opened this issue Jul 8, 2020 · 2 comments

Comments

@Audrius-GR
Copy link

Similar to #799, seems if the group is empty, you end up with just a [\n

Dummy message that I think reproduces this:

  <sbe:message name="myMessage" id="6">
    <field name="myId" id="2" type="uint32"/>
    <group name="myGroupInfo" id="7" dimensionType="groupSizeEncoding">
      <field name="internalId" id="2" type="idtype"/>
      <field name="otherId" id="3" type="idType"/>
    </group>
    <data name="rawStringId" id="100" type="varDataEncoding"/>
  </sbe:message>

results in:

{
    "myId": 0,
    "myGroupInfo": [
    "rawStringId": ""
}
@Audrius-GR
Copy link
Author

It seems that the [\n is created by onGroupHeader, and ],\n should be created by onEndGroup, but onEndGroup is only called if there are more than 0 elements in the group.

@Audrius-GR
Copy link
Author

I think the easiest way around this is to handle terminating the array in onGroupHeader if numInGroup = 0

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants