内部添加内容:
$json = @"
{
"BlockA": {
"BlockB": {
"name": "BlockB",
"value": "Value_B"
}
}
}
"@
$blockcvalue =@"
{
"name":"BlockC",
"value":"ValueC"
}
"@
$jobj = ConvertFrom-Json -InputObject $json
$jobj.BlockA | add-member -Name "BlockC" -value (Convertfrom-Json $blockcvalue) -MemberType NoteProperty
write-host (ConvertTo-Json $jobj)
外部添加内容
$json = '{"mem":[[1377691200,10],[1377770400,0]],"proc":[[1377691200,80],[1377770400,0]]}'
$jobj = ConvertFrom-Json -InputObject $json
$datetime = 1377780400
$proc = 85
$add = @($datetime, $proc)
$jobj.proc += ,$add
cls
ConvertTo-Json $jobj