Hello,
recently I’ve found HJSON and I think it’s wonderful. But I have trouble during usage with PowerShell via c# implementation from GitHub - hjson/hjson-cs: Hjson for C#.
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: hjson-cs/test.hjson at master · hjson/hjson-cs · GitHub
I’ve try to follow examples from Github Readme:
- 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();
Powershell:
$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:
[Hjson.JsonUtil]::Qs($data,"hello")
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?