Project

Profile

Help

Bug #2692

Incorrect output from xml-to-json function, for an empty array inside an array

Added by Debbie Lockett about 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Category:
XSLT conformance
Sprint/Milestone:
Start date:
2016-04-01
Due date:
% Done:

100%

Legacy ID:
Applies to branch:
9.7
Fix Committed on Branch:
9.7
Fixed in Maintenance Release:

Description

Raised by a user on the support mailing list.

Applying the xml-to-json() function to the following input:

<number>3</number>

<array/>

<number>4</number>

Returns the JSON output:

[3,[]4]

i.e. there is a comma separator missing after the empty array.

History

#1 Updated by Michael Kay about 4 years ago

Also applies where an empty map is output within an array.

#2 Updated by Debbie Lockett about 4 years ago

  • Status changed from New to In Progress
  • Assignee set to Debbie Lockett

#3 Updated by Debbie Lockett about 4 years ago

Tests xml-to-json-A014, xml-to-json-A015, xml-to-json-B014, xml-to-json-B015 added to the XSLT 3.0 test suite. Testing both empty arrays and empty maps inside an array.

#4 Updated by Debbie Lockett about 4 years ago

  • Status changed from In Progress to Resolved
  • Fix Committed on Branch 9.7 added

The problem was that JsonReceiver was not setting atStart to false after processing an empty map or array.

Fix made to JsonReceiver.endElement() to set atStart=false unconditionally.

Patch committed on 9.7 and dev branches.

#5 Updated by Debbie Lockett about 4 years ago

Another user has pointed out that the same bug affects maps containing an empty map or array as the value of a pair (which is not the last).

e.g. xml-to-json(json-to-xml({A":{},"B":1})) returns {"A":{}"B --- with a missing comma.

The patch already committed for this bug fixes this issue. Further new tests (xml-to-json-A017, A018, B017, B018) have been added to the XSLT 3.0 test suite.

#6 Updated by O'Neil Delpratt almost 4 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 9.7.0.5 added

Bug fix applied in the Saxon 9.7.0.5 maintenance release.

#7 Updated by O'Neil Delpratt almost 4 years ago

  • Sprint/Milestone set to 9.7.0.5

Please register to edit this issue

Also available in: Atom PDF