如果在這樣的數字列之一中保存具有空值的表,則如下所示:
New Table( "testEmpty",
Add Rows( 2 ),
New Column( "Col1",
Character,
"Nominal",
Set Selected,
Set Values( {"test", "test"} )
),
New Column( "Col2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [., .] )
)
)作為JSON文件,結果如下:
[
{
"Col1" : "test",
"Col2" : .
},
{
"Col1" : "test",
"Col2" : .
}
]似乎並非所有人都同意這是有效的JSON語法。 如果我使用Powershell將該文件讀回到JSON,
$json = Get-Content -Path 'C:\Users\myUser\testEmpty.json' -ErrorAction Stop | ConvertFrom-Json
它會出錯:
ConvertFrom-Json : Invalid JSON primitive: ..
At C:\Users\myUser\testEmpty.ps1:1 char:118
+ ... \myUser\testEmpty.json' -ErrorAction Stop | ConvertFrom-Json
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [ConvertFrom-Json], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand
任何想法如何解決這個問題? 使用腳本保存JSON文件時有什麼選擇? 還是唯一的解決方法是確保表中沒有空值?