Reputation: 24768
I have this in my YAML file:
test: I want spaces before this text
In my case I would like to have a space before the text in my array or json when converted. Is that possible? How?
With JSON as output it's parsed like this:
{
"test": "I want spaces before this text"
}
No spaces.
You can test it here
Upvotes: 7
Views: 23610
Reputation: 121
With \t this work
Example:
var options = {
\t hostname: 'localhost',
\t port: 4433
};
Upvotes: -2
Reputation: 76634
You would have to quote your scalar with either single or double quotes instead of using a plain scalar (i.e. one without quotes). Which one of those two is more easy to use depends on whether there are special characters in your text.
If you use single quotes:
test: ' I want spaces before this text'
this would require doubling any single quotes already existing in your text
(something like ' abc''def '
).
If you use double quotes:
test: " I want spaces before this text"
this would require backslash escaping any double quotes already existing in your text
(something like " abc\"def "
).
Upvotes: 8