I'm trying to use HJSON C# library for PowerShell: https://github.com/hjson/hjson-cs I've successfully compiled the dll, put it into a folder and added the type via standard procedure:
#LOAD
$scriptRoot = Split-Path $script:psEditor.GetEditorContext().CurrentFile.Path
$FilePath = ( Get-Item .\Hjson.dll ).FullName
[System.Reflection.Assembly]::LoadFrom("$FilePath")
[Hjson.IJsonReader]::new()
[Hjson.hjson]::Load("$scriptRoot\test.hjson")
I'm trying to follow examples to get the basics:
Read method: https://github.com/hjson/hjson-cs#read
# var jsonObject = HjsonValue.Load(filePath).Qo();
$jsonTempData = [Hjson.HjsonValue]::Load("$scriptRoot\test.hjson")
$jsonObject = [Hjson.JsonUtil]::Qo($jsonTempData)
$jsonObject
but the output is missing values:
PS D:\OneDrive\PS-HJSON> $jsonObject
Key Value
--- -----
hello
text
quote
otherwise
abc-123
commas
but
trailing
multiline
number
negative
yes
no
null
array
array2
PS D:\OneDrive\PS-HJSON>
So I can't see values. Why it doesn't work like JSON objects?
And when I try to iterate through keys:
foreach ( $item in $jsonObject) {
$item.Key, $item.Value
}
I got this:
The following exception occurred while trying to enumerate the collection: "The operation is invalid due to the current state of the object. "
I'm sure I'm missing something, but I don't know c# enough to know what to do.