json2yaml | A command-line utility convert a JSON file | JSON Processing library
kandi X-RAY | json2yaml Summary
kandi X-RAY | json2yaml Summary
A command-line utility to convert a JSON file (.json) to YAML (.yml)
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Serialize the given data .
- Read input .
- read in line
- Handles input text
- read file
- Prints usage
json2yaml Key Features
json2yaml Examples and Code Snippets
Community Discussions
Trending Discussions on json2yaml
QUESTION
How do I write a regular expression in yaml across multiple lines that, when converted to json, is a single line without extra spaces or comments?
The VSCode docs outline a way to write a single regular expression in yaml that spans multiple lines with comments. I've tried their suggestions, and my output always includes the newlines and comments.
Here's the yaml from their example, saved at syntaxes/abc.tmLanguage.yaml
:
ANSWER
Answered 2020-Apr-04 at 11:20None of that is a problem if you process the regex in free-spacing mode. The comments and whitespace will be thrown away by the regex engine. Folded scalars in YAML will produce at least one space token per line break, so you can't really use it to write regexes without free-spacing mode anyway.
Here's a breakdown why YAML parses your input like this:
The first issue is a peculiar definition in the spec about the handling of folded scalars:
Lines starting with white space characters (more-indented lines) are not folded.
Your first line defines the indentation of the folded scalar. Since all other lines are more indented, they start with space characters and thus all line breaks are kept.
The second issue is that you seem to assume that YAML recognizes comments within a folded scalar, which it doesn't. A folded scalar treats all contained characters as content. Since what you intend to be comments are treated as content, so is the whitespace before those comments.
There are only two ways of commenting a folded scalar in YAML:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install json2yaml
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page