【.cmd】 バッチファイルスクリプト %15 【.bat】at TECH
【.cmd】 バッチファイルスクリプト %15 【.bat】 - 暇つぶし2ch267:デフォルトの名無しさん
23/05/06 18:58:59.94 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}}"


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch