Coder Social home page Coder Social logo

Comments (4)

EverNife avatar EverNife commented on July 23, 2024 1

Thankyou, its properly fixed :D

from simple-yaml.

Carleslc avatar Carleslc commented on July 23, 2024

Seems related to #43.

With snakeyaml indicatorIndent to 0 (i.e. with no list indentation at all) it works as expected:

...
  peoples:
  - *id001
  - ==: org.simpleyaml.examples.Person
    dni: 12345678B
    name: Maria
    birthYear: 1990
    isAlive: true

This is valid YAML because - character is considered to be indentation as per the YAML spec (see this comment).

This was the prior default behaviour, but it was changed in 1.7.1 to improve indentation consistency, so now indicatorIndent is set to the same value as indent (2 by default).

With newer versions of snakeyaml it seems to be a valid alternative for lists of maps using the same value for both indent and list indentation (snakeyaml issue 416), so I will update the default options to set this indentWithIndicator option.

An indentList option will be added to YamlConfigurationOptions to change the list elements indentation if desired.

from simple-yaml.

EverNife avatar EverNife commented on July 23, 2024

You are right!

...yml
  peoples:
  - *id001
  - ==: org.simpleyaml.examples.Person
    dni: 12345678B
    name: Maria
    birthYear: 1990
    isAlive: true

Is a valid YML, But

  peoples:
    - *id001
    -
    ==: org.simpleyaml.examples.Person
    dni: 12345678B
    name: Maria
    birthYear: 1990
    isAlive: true

is not!

I think for now is easier to add an option to YamlConfigurationOptions to set setIndicatorIndent
And change the default value to 0 rather than the 2 that is now

from simple-yaml.

Carleslc avatar Carleslc commented on July 23, 2024

I have just released 1.7.3 with the YamlConfigurationOptions::indentList option to change the indicatorIndent (list elements indentation).

It is still 2 by default, but now it should work properly for serialized objects and maps with the indentWithIndicator change.

You can set yamlFile.options().indentList(0) if you prefer having no extra indentation for your list elements.

Now your example output is valid YAML without any addition:

test:
  people:
    12345678A: &id001
      ==: org.simpleyaml.examples.Person
      dni: 12345678A
      name: John
      birthYear: 1990
      isAlive: true
peoples:
  - *id001
  - ==: org.simpleyaml.examples.Person
    dni: 12345678B
    name: Maria
    birthYear: 1990
    isAlive: true

from simple-yaml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.