Skip to content

Fix ConvertFrom-Json to handle mutlilines #956

Closed

Description

This makes scenarios such as working with REST APIs very annoying. Additionally, Linux does not usually use a BOM in a UTF-8 string.

Activity

  1. added
    Usability
    on May 6, 2016
  2. joeyaiello commented on May 6, 2016

    @joeyaiello
    Contributor

    #707 is somewhat related (PowerShell is using UTF-8 w/ a BOM by default and this is not the norm on *nix)

  3. changed the title [-]PowerShell appends BOM to all UTF-8 strings[/-] [+]PowerShell prepends BOM to all UTF-8 strings[/+] on May 6, 2016
  4. added
    Issue-Bug
    on May 6, 2016
  5. andyleejordan commented on May 6, 2016

    @andyleejordan
    MemberAuthor

    Having to do $json = $response.substring(1) | convertfrom-json is really bad UX.

  6. joeyaiello commented on May 11, 2016

    @joeyaiello
    Contributor

    Totally agreed. Filing a bug on Francisco Gamino (@Francisco-Gamino) to fix it in SD (unfortunately, he still has to live there because Nano).

  7. andyleejordan commented on May 16, 2016

    @andyleejordan
    MemberAuthor

    Repro:

    > curl -s -L https://api.github.com/users/andschwa | ConvertFrom-Json
    ConvertFrom-Json : Unexpected end when reading JSON. Path '', line 1, position 1.
    At line:1 char:52
    + curl -s -L https://api.github.com/users/andschwa | ConvertFrom-Json
    +                                                    ~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [ConvertFrom-Json], JsonSerializationException
        + FullyQualifiedErrorId : Newtonsoft.Json.JsonSerializationException,Microsoft.PowerShell.Commands.ConvertFromJsonComman
       d
    
  8. changed the title [-]PowerShell prepends BOM to all UTF-8 strings[/-] [+]Fix ConvertFrom-Json to handle text with/without BOM[/+] on Jun 8, 2016
  9. modified the milestones: , Aug17 on Jul 19, 2016
  10. joeyaiello commented on Jul 20, 2016

    @joeyaiello
    Contributor

    Not sure what's going on, but the substring workaround doesn't work anymore. On the other hand, $json | Out-String | ConvertFom-Json seems to work fine for reasons unbeknownst to me

  11. joeyaiello commented on Jul 21, 2016

    @joeyaiello
    Contributor

    Bruce Payette (@BrucePay) maybe you know what's going on here?

  12. modified the milestones: , 6.0.0-alpha.8 on Jul 21, 2016
  13. changed the title [-]Fix ConvertFrom-Json to handle text with/without BOM[/-] [+]Fix ConvertFrom-Json to handle mutlilines[/+] on Jul 26, 2016
  14. vors commented on Jul 26, 2016

    @vors
    Collaborator

    This doesn't have to do anything with BOM actually.

    Here is the simpler repro

    ('{', '}') | ConvertFrom-Json 
    

    Expected

    Empty object (this is behaviour on Full PS)

    Actual

    ConvertFrom-Json : Unexpected end when deserializing object. Path '', line 1, position 1.
    At line:1 char:14
    + ('{', '}') | ConvertFrom-Json
    +              ~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [ConvertFrom-Json], JsonSerializationException
        + FullyQualifiedErrorId : Newtonsoft.Json.JsonSerializationException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand
    
  15. added a commit that references this issue on Aug 6, 2026
    ec9718d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Issue-BugUsability

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions