Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7062265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:34:23+00:00 2026-05-28T04:34:23+00:00

I seem to see double-spaced output when parsing/dumping a simple YAML file with a

  • 0

I seem to see double-spaced output when parsing/dumping a simple YAML file with a pipe-text field.

The test is:

public void yamlTest() 
{
    DumperOptions printOptions = new DumperOptions();
    printOptions.setLineBreak(DumperOptions.LineBreak.UNIX);
    Yaml y = new Yaml(printOptions);
    String input = "foo: |\n" +
            "      line 1\n" +
            "      line 2\n";
    Object parsedObject = y.load(new StringReader(input));
    String output = y.dump(parsedObject);
    System.out.println(output);
}

and the output is:

{foo: 'line 1

    line 2

    '}

Note the extra space between line 1 and line 2, and after line 2 before the end of the string.

This test was run on Mac OS X 10.6, java version “1.6.0_29”.

Thanks!

Mark

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:34:24+00:00Added an answer on May 28, 2026 at 4:34 am

    In the original string you use literal style – it is indicating by the ‘|’ character. When you dump your text, you use single-quoted style which ignores the ‘\n’ characters at the end. That is why they are repeated with the empty lines.
    Try to set different styles in DumperOptions:

    // and others - FOLDED, DOUBLE_QUOTED
    DumperOptions.setDefaultScalarStyle(ScalarStyle.LITERAL) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't seem to see the forest for the trees right now (Looked at
So I see that Assert has dozens of methods that seem to do essentially
I see there is version 1.5 and 3.0 beta , but I can't seem
I know this may seem trivial to some, other won't see the point, however
If I use the url tag with double quotes: @{/public/images/blue.png} I get this error:
I'm adding full-text search to my Rails site and allowing users to enter double
Seem to run into a service endpoint not found problem when trying to get
Seem to be having some issues storing the current date in a core data
There seem to be very different opinions about using transactions for reading from a
I seem to be having a very frustrating time with an inherited class calling

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.