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(LEGACY) Helps filter issues that might be higher priority because they directly affect 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. andyleejordan commented on May 6, 2016

    @andyleejordan
    MemberAuthor

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

  5. 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).

  6. 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
    
  7. changed the title [-]PowerShell prepends BOM to all UTF-8 strings[/-] [+]Fix ConvertFrom-Json to handle text with/without BOM[/+] on Jun 8, 2016
  8. modified the milestones: , Aug17 on Jul 19, 2016
  9. 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

  10. joeyaiello commented on Jul 21, 2016

    @joeyaiello
    Contributor

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

  11. modified the milestones: , 6.0.0-alpha.8 on Jul 21, 2016
  12. changed the title [-]Fix ConvertFrom-Json to handle text with/without BOM[/-] [+]Fix ConvertFrom-Json to handle mutlilines[/+] on Jul 26, 2016
  13. 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
    
  14. 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-BugIssue has been identified as a bug in the productUsability(LEGACY) Helps filter issues that might be higher priority because they directly affect usability

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions