BaseXdb / basex

BaseX Main Repository.
http://basex.org
BSD 3-Clause "New" or "Revised" License
678 stars 268 forks source link

Identation is disabled by default for JSON serialization in 10.3 #2150

Closed dliakh closed 1 year ago

dliakh commented 1 year ago

Description of the Problem

The JSON module documentation (https://docs.basex.org/wiki/Serialization) states that the 'indent' option is enabled by default (and it was in 9.7.3, for example) and in 10.3 it's disabled by default:

$ java -cp ~/BaseX103.jar org.basex.BaseX 'json:serialize(array {1, 2, 3, map {1 : array {1, 2, 3}}})'
[1,2,3,{"1":[1,2,3]}]

$ java -cp ~/BaseX973.jar org.basex.BaseX 'json:serialize(array {1, 2, 3, map {1 : array {1, 2, 3}}})'
[
  1,
  2,
  3,
  {
    "1": [
      1,
      2,
      3
    ]
  }
]

Expected Behavior

The default for the 'indent' option is like in the documentation

Steps to Reproduce the Behavior

  1. Try calling json:serialize() to serialize some relatively complex structure that should produce multi-line formatted output (if the 'indent' option is enabled.
  2. Check the output is all in one line (and not indented)
  3. Try the same query with an older version of BaseX (for example 9.7.3)

Do you have an idea how to solve the issue?

No response

What is your configuration?

Ubuntu 22.0.4, openjdk 17.0.5 2022-10-18, BaseX 10.3

ChristianGruen commented 1 year ago

Thanks for the observation.

The JSON module documentation (https://docs.basex.org/wiki/Serialization) states that the 'indent' option is enabled by default

In the documentation, we tried to indicate that the default has changed with version 10 (see also the changelog):

image

Maybe there’s another piece in the documentation that tells otherwise? Could you please give us additional hints?

ChristianGruen commented 1 year ago

An addendum: With BaseX 11, it will be possible to enforce indentation on command-line via -W. A beta implementation is already available in BaseX 10.3.

dliakh commented 1 year ago

Hi Christian, This is the document: https://docs.basex.org/wiki/JSON_Module#Options

(the default for the indent option is specified as 'yes')

Thank you for your prompt response Best regards

ChristianGruen commented 1 year ago

Thanks; I have updated our documentation.

dliakh commented 1 year ago

Thank you very much