convertfrom-json is truncating json info while parsing it

Welcome Forums DSC (Desired State Configuration) convertfrom-json is truncating json info while parsing it

This topic contains 1 reply, has 2 voices, and was last updated by

2 years, 2 months ago.

  • Author
  • #60244

    Points: 0
    Rank: Member

    Input json file (src.json) is shown below
    The below json file has 3 columns viz. time, type, message. And it has 2 rows of such information. The 2nd line has long message

    {"time": "2016-12-14T08:56:47.622-8:00", "type": "verbose", "message": "hello world"},
    {"time": "2016-12-14T09:03:20.040-8:00", "type": "verbose", "message": "sadlhasdlhsadlhasdlhasldhasldhlashdlashd sdlasldlashdlashdlashdlhaslkhaslkdhlashdlashdlkashdlkashdlashdlkasldhaslkdhad134324324324324234234234234324234kllklnlllnnlnlnlkjn2343242342349999999999999lnlnlknlknlknlknlkxxxxxxxxxxxxxxxxxxxxxxx12345"}

    I use the below powershell code to parse the above json file content and output it to a text file
    $content=Get-Content "d:\src.json" -Raw
    ConvertFrom-Json $content | out-file "D:\dest.txt"

    The output file "dest.txt" is shown below
    time type message
    —- —- ——-
    2016-12-14T08:56:47.622-8:00 verbose hello world
    2016-12-14T09:03:20.040-8:00 verbose sadlhasdlhsadlhasdlhasldhasldhlashdlashd sdlasldlashdlashdlashdlhaslkhaslkdhlashdlashdlkashdlkashdlashdlkasldhaslkdhad134324324324324234234234234324234kllklnlllnnlnlnlkjn234324234234999999...

    As you can see the 2nd row's message portion is truncated. You can "..." at the end of the message.

    Can I know why convertfrom-json truncates it?

  • #60409

    Points: 24
    Team Member
    Rank: Member

    According to the documentation (Notes section) on MSDN of the Out-File cmdlet sends unformatted object to a formatting cmdlet. Which is Format-Table in your case before writting the file to disk.

    I hope that helps.

The topic ‘convertfrom-json is truncating json info while parsing it’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort