Types/OpenPackage.Part/ReadJsonL.ps1

<#
.SYNOPSIS
    Reads Part Content as Json Lines
.DESCRIPTION
    Reads Open Package Part Content as Json Lines
.NOTES
    Also should work for asciienma `.cast` files and `.jsonnd`,
    which are also json files delimited by newlines.
#>

[Reflection.AssemblyMetadata(
    'FilePattern', 
    '\.(?>cast|jsonl|jsonnd)?$'
)]
param(
    # An optional input object
    # If provided, content will be read from this object.
    # If not provided, content will be read from this part.
    [Alias('Input')]
    [PSObject]$InputObject = $null,
 
    # Any options used to read the data.
    [Alias('Options')]
    [Collections.IDictionary]$Option = [Ordered]@{}
)
if (-not $this.ReadText) { return }
$partText = $this.ReadText($InputObject, $Option)
# This is faster than the cmdlet ConvertFrom-Json
$ConvertFromJson = [Microsoft.PowerShell.Commands.JsonObject]::ConvertFromJson
if (-not $ConvertFromJson) { return }

foreach ($line in $partText -split '(?>\r\n|\n)') {
    $ConvertFromJson.Invoke(
        $line, $option.hashtable, $option.Depth, [ref]$null
    )    
}