This topic contains 2 replies, has 2 voices, and was last updated by
April 10, 2018 at 8:09 pm #98395ParticipantTopics: 1Replies: 1Points: 0Rank: Member
Since github repository doesn't contain .dll, in order to test/help you need to compile project or download this compiled dll: https://ufile.io/phont
The test file which I use is: https://github.com/hjson/hjson-cs/blob/master/sample/test.hjson
I've try to follow examples from Github Readme:
0. Load into Powershell:
$FilePath = ( Get-Item .\Hjson.dll ).FullName [System.Reflection.Assembly]::LoadFrom("$FilePath")
it works, type [Hjson] is successfully loaded
var jsonObject = HjsonValue.Load(filePath).Qo();
$data = [Hjson.HjsonValue]::Load("$scriptRoot\test.hjson") [Hjson.JsonUtil]::Qo($data)
it works but the output shows only keys but not values:
PS D:\OneDrive\PS-HJSON> $data = [Hjson.HjsonValue]::Load("$scriptRoot\test.hjson") [Hjson.JsonUtil]::Qo($data) Key Value --- ----- hello text text2 quote otherwise abc-123 commas but trailing multiline number negative yes no null array array2
and I can't get values also like this:
$data.Values #The following exception occurred while trying to enumerate the collection: "Operation is not valid due to the current state of the object."
the only way to get values is:
but this is tedious and I'm sure that I'm missing something. So my general question is: the errors and behaviors are due the c# code/implementation? Or I'm using it in wrong way?
April 15, 2018 at 3:30 pm #98844KeymasterTopics: 13Replies: 4872Points: 1,811Rank: Community Hero
Sorry for this being a delayed reply; we were all busy at Summit.
Honestly, this is kind of so far outside the PowerShell orbit I'm not sure what to offer. Have you considered opening an issue on the project's repo?
April 22, 2018 at 10:58 am #99433ParticipantTopics: 1Replies: 1Points: 0Rank: Member
Hello Don, no need to apologize,
Indeed it's outside of the scope of the Powershell, but I've asked also at the Powershell Slack/StactOverflow: https://stackoverflow.com/questions/49783149/hjson-c-sharp-library-for-powershell
and one of the developers with c# backgroud explain this issue and provide solution:
Just convert HJSON to json ( via provided method) as PowerShell is a lot better at handling that
The topic ‘HJSON usage problems’ is closed to new replies.