c# - Deserialize PSON file -


i have task of de-serializing pson (powershell object notation) file , struggling working. apparently pson file variant of json used puppet encodes strings differently - according this source

i have tried using standard json.net deserializeobject method:

using (var r = new streamreader(psonfilepath)) {     string json = r.readtoend();     dynamic jsonobject = jsonconvert.deserializeobject(json); } 

the above code throws exception:

"unexpected character encountered while parsing value: @. path '', line 0, position 0."

which makes sense standard json file wouldn't have '@' @ start.

an example of pson file below:

@{     shapes = @{         'sq4297' = @{             shapeid = 'sq4297'             shapetype = 'square'             sides = 'four'             colour = 'purple'         }         'sq6281' = @{             shapeid = 'sq6281'             shapetype = 'square'             sides = 'four'             colour = 'orange'         }         'tr14' = @{             shapeid = 'tr14'             shapetype = 'triange'             sides = 'three'             colour = 'green'         }     } } 

the link mentioned above states that

most parsers produce usable output pson if instructed interpret input latin-1 encoding

i have tried using different encodings json similar errors whichever way try. tried removing '@' run problems because strings not enclosed in quotes parser exceptions again.

i think there 2 different meanings of pson here.

  1. pson in relation powershell, refers powershell object notation. format used store powershell data objects in file. 1 useful feature of pson file can de-serialize when executed in powershell.

    for more information see question: save hash table in powershell object notation (pson)

    the file in question, valid powershell pson file.

  2. the other pson seems protocol json . "a super efficient binary serialization format json" this, know nothing about.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -