powershell - "Invalid JSON primitive" error when converting JSON file -


when trying convert json file via powershell:

$json = get-content "c:\folder1\test.txt"  $json | convertfrom-json   write-output $json 

i'm getting following error:

invalid json primitive : [.
(system.argunment.exception)

i'm going out on limb here, since didn't provide input data or complete error message, guess problem caused format mismatch between output get-content provides , input convertfrom-json expects.

get-content reads input file array of strings, whereas convertfrom-json expects json data in single string. also, piping $json convertfrom-json not change value of $json.

change code following , error should disapear (provided there no syntactical error in input data):

$json = get-content 'c:\folder1\test.txt' | out-string | convertfrom-json  write-output $json 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -