Skip to content

isArray empty array produces an array with a single string #549

Open
@chriscarpenter12

Description

@chriscarpenter12
  • Are you running the latest version?
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration?
  • Did you try online tool?

Description

When using the isArray to specify which tags should be an array. If the tag is empty it produces an output with an array of a single empty string. [""] instead of the expected [].

Input

<root>
    <EventList></EventList>
</root>

Code

new XMLParser({
    ignoreAttributes: true,
    isArray: (name) => {
      return name.endsWith('List');
    },
  });
trimValues: true,
parseTagValue: true,

These don't seem to have any change on output in this scenario either.

Output

{
  "EventList": [
    ""
  ],
}

expected data

{
  "EventList": [],
}

Would you like to work on this issue?

  • Yes
  • No

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions