Code Monkey home page Code Monkey logo

Comments (3)

gabriel-samfira avatar gabriel-samfira commented on September 14, 2024

Hi Tim,

Due to the way PowerShell treats ValueFromPipeline, it is almost impossible to differentiate between:

$content = Get-Content test.txt
$content.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Object[]                                 System.Array

and

$content = @("first line", "second line", "third line")

The -Raw flag gives you just one String element, so that works as expected.

For ConvertFrom-Yaml we could wait until we read all elements from a pipeline before we attempt to parse it, but it will break situations where you're sending in an array where each element is a valid yaml.

Will take a look at this more by the end of the week.

from powershell-yaml.

gabriel-samfira avatar gabriel-samfira commented on September 14, 2024

Apologies for taking so long. Would you mind testing the latest commint on the master branch?

PS /tmp/powershell-yaml> cat ./test.yaml
---
id: m1
isRoot: true
delay: 0
text: Test

---
another: document
PS /tmp/powershell-yaml> gc ./test.yaml | ConvertFrom-Yaml

Name                           Value
----                           -----
isRoot                         True
id                             m1
text                           Test
delay                          0

PS /tmp/powershell-yaml> gc ./test.yaml | ConvertFrom-Yaml -AllDocuments

Name                           Value
----                           -----
isRoot                         True
id                             m1
text                           Test
delay                          0
another                        document

PS /tmp/powershell-yaml> gc -Raw ./test.yaml | ConvertFrom-Yaml         

Name                           Value
----                           -----
isRoot                         True
id                             m1
text                           Test
delay                          0

PS /tmp/powershell-yaml> gc -Raw ./test.yaml | ConvertFrom-Yaml -AllDocuments

Name                           Value
----                           -----
isRoot                         True
id                             m1
text                           Test
delay                          0
another                        document

from powershell-yaml.

timia2109 avatar timia2109 commented on September 14, 2024

Thank you!

Works as expected like ConvertFrom-Json 👍

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.