- 267 名前:デフォルトの名無しさん mailto:sage [2023/05/06(土) 18:58:59.94 ID:l5Xh2UOq.net]
- powershellで
$json_string = @' [{"characterID": 1,"Level": 50, "Status": {"idx":1}}, {"characterID": 1,"Level": 100, "Status": {"idx":2}}, {"characterID": 2,"Level": 50, "Status": {"idx":3}}, {"characterID": 3,"Level": 50, "Status": {"idx":4}}, {"characterID": 3,"Level": 100, "Status": {"idx":5}}] '@ $json = $json_string | ConvertFrom-Json $json | group characterID | select @{N='ID';E={$_.Name}},@{N='MaxL';E={[int]($_.group | measure -Maximum Level).Maximum}} | %{ $id=$_.ID; $maxl=$_.MaxL; $json | ?{ $id -eq $_.characterID -and $maxl -eq $_.Level}} 出力結果 characterID Level Status ----------- ----- ------ 1 100 @{idx=2} 2 50 @{idx=3} 3 100 @{idx=5} バッチファイルから呼び出す場合 set FILENAME=test.txt powershell -c "$json=gc %FILENAME% | ConvertFrom-Json; $json | group characterID | select @{N='ID';E={$_.Name}},@{N='MaxL';E={[int]($_.group | measure -Maximum Level).Maximum}} | %%{ $id=$_.ID; $maxl=$_.MaxL; $json | ?{ $id -eq $_.characterID -and $maxl -eq $_.Level}}"
|

|