Giter Club home page Giter Club logo

Comments (2)

gabriel-samfira avatar gabriel-samfira commented on June 29, 2024

Hi @ephos,

First of all, my apologies for not getting back to you sooner.

Secondly, I tried this:

PS /home/gabriel> $data = @'
>> something:
>>   name: test
>>   key: |
>>     -----BEGIN PGP MESSAGE-----
>>     Version: GnuPG v2.0.22 (GNU/Linux)
>>     blah
>>     blah
>>     blah
>>     -----END PGP MESSAGE-----
>> '@
PS /home/gabriel> $x = ConvertFrom-Yaml $data
PS /home/gabriel> $x["something"]["key"]
-----BEGIN PGP MESSAGE-----
Version: GnuPG v2.0.22 (GNU/Linux)
blah                              
blah                                     
blah       
-----END PGP MESSAGE-----
           
PS /home/gabriel> ConvertTo-Yaml $x          
something:             
  key: |        
    -----BEGIN PGP MESSAGE-----
    Version: GnuPG v2.0.22 (GNU/Linux)
    blah
    blah
    blah
    -----END PGP MESSAGE-----
  name: test

Would you mind pasting an example of what you tried?

from powershell-yaml.

ephos avatar ephos commented on June 29, 2024

Sorry I also just saw this reply! I just tried it out and it looks like it may work, I am going to try it tomorrow to see if it fixes what I saw when I originally opened the issue. Below is what I tried and it seems to honor the multi line string.

$yaml = @"
something:
  name: test
  key: |
    -----BEGIN PGP MESSAGE-----
    Version: GnuPG v2.0.22 (GNU/Linux)
    blah
    blah
    blah
    -----END PGP MESSAGE-----
"@

# Deserialize
$object = $yaml | ConvertFrom-Yaml

# Updated value
$newPGPMsg = @"
-----BEGIN PGP MESSAGE-----
Version: GnuPG v2.0.22 (GNU/Linux)
foo
foo
foo
-----END PGP MESSAGE-----
"@

# Update the value
$object.something.key = $newPGPMsg
$object.something.key 

# Serialize back to YAML
$object | ConvertTo-Yaml

from powershell-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.