Project

Profile

Help

Feature #4991

closed

Do indentation of JSON with xml-to-json($json-xml, map { 'indent' : true() })

Added by Martin Honnen over 3 years ago. Updated 2 months ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
-
Sprint/Milestone:
Start date:
2021-05-16
Due date:
% Done:

100%

Estimated time:
Applies to JS Branch:
2, Trunk
Fix Committed on JS Branch:
2, Trunk
Fixed in JS Release:
SEF Generated with:
Platforms:
Company:
-
Contact person:
-
Additional contact persons:
-

Description

The function xml-to-json takes an optional second argument with a map for options, the one being defined is a boolean value for the key indent.

While the Java and .NET product honour that option and do indent any produced JSON, Saxon-JS 2 doesn't do any indentation, see also https://saxonica.plan.io/boards/5/topics/8052?r=8053#message-8053.

It would be nice if the implementation could be enhanced to support indentation as otherwise reading the result of xml-to-json that Saxon-JS 2 produces is very hard as you are faced with one long line of JSON data.

Actions #2

Updated by Norm Tovey-Walsh over 2 years ago

  • Sprint/Milestone set to SaxonJS 3.0
Actions #3

Updated by Norm Tovey-Walsh 5 months ago

Indeed, the implementation of xml-to-json diligently checks that the indent option is a boolean then...never mentions it again. :-(

Actions #6

Updated by Norm Tovey-Walsh 5 months ago

  • Status changed from New to Resolved
  • Applies to JS Branch Trunk added
  • Fix Committed on JS Branch 2, Trunk added

I've added support for the indent option. It's not exactly what JavaScript does when asked to produce indented JSON, but it certainly introduces sufficient line breaks and indentation to be readable.

Actions #7

Updated by Debbie Lockett 2 months ago

The code changes inadvertently introduced a regression: causing the xslt30 test xml-to-json-C016 to fail.

i.e. @key and @escaped-key are permitted on a root element, not only on the child of a map (see Saxon Bug #3000: Spec change (bug 29917) - @key and @escaped-key allowed on root of input to xml-to-json() for details).

I've committed an update to fix this, on the main and saxonjs2 branches.

Actions #8

Updated by Debbie Lockett 2 months ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in JS Release set to SaxonJS 2.7

Bug fix applied in the SaxonJS 2.7 maintenance release.

Please register to edit this issue

Also available in: Atom PDF Tracking page