Comments (6)
Thanks for reporting - unfortunately this is tricky since after round-tripping through JSON, there is no metadata on what kind of block the original text was. We could probably configure PyYAML to write all multiline strings as literal blocks or folded blocks, but I'm not sure if that's always the best thing to do, or what else to do to improve this.
from yq.
I see two issues:
- Added newlines between the 3 lines in the example, completely breaking/altering the value
- yq should preserve the type, and not replace a literal block or folded block with a quoted multiline string.
Both should be fixed imho but I guess the first one is easier.. ?
Is there any corresponding issue at the PyYAML that would help yq with this ?
from yq.
The first observation that you make is not an issue. The two constructs in the description are equivalent in YAML. See the YAML spec and https://yaml-multiline.info/ for a thorough explanation of this.
As I mentioned in my previous comment, there is no metadata preserved in JSON on what kind of block the original string was. As such there is no obvious way to solve the second issue that you mention under the design constraints of yq.
from yq.
Awesome, thx !!
from yq.
Is this the desired behaviour ?
This looks pretty well:
❯ cat y
some:
file: |
hello world
line1
line2
❯ yq -Y . < y
some:
file: |
hello world
line1
line2
❯ yq -Y .some < y
file: |
hello world
line1
line2
But when I query the exact key, the literal block is not presered anymore:
❯ yq -Y .some.file < y
'hello world
line1
line2
'
from yq.
Yes. You don't need -Y when all you're doing is extracting the leaf node.
from yq.
Related Issues (20)
- A scalar starting with 00 (double zero) is interpreted as octal number HOT 2
- Use python built in TOML support? HOT 4
- [xq] Parse optional schema (xsd) file to determine the types for better json output HOT 1
- Array indexing diverges from jq syntax HOT 3
- Some advice about license compliance HOT 1
- Parsing nmap's XML: single script node into object, multiple script nodes into array HOT 4
- add `fromyaml` like jqs `fromjson` HOT 3
- tomlq throws TypeError on documents containing date-time values HOT 1
- test output too noisy HOT 1
- order of parameters changes behavior HOT 1
- Add indentation & improve sorting of TOML output HOT 4
- Python 3.6 installation from PyPI broken HOT 4
- XML streaming mode HOT 2
- ConstructorError: found unconstructable recursive node HOT 2
- Tests fail with a variety of errors: argparse.ArgumentError: argument files: can't open '/dev/fd/3': [Errno 2] No such file or directory: '/dev/fd/3', etc HOT 1
- xml: is keeping the namespace possible? HOT 1
- Test fails with jq-1.7 HOT 1
- Ubuntu 23.04 disallows `pip install yq` by default HOT 2
- output string '08' and '09' without quote using yaml output format HOT 1
- xq no longer outputting JSON HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yq.