Json & Powershell query Select

Welcome Forums General PowerShell Q&A Json & Powershell query Select

This topic contains 1 reply, has 2 voices, and was last updated by

1 year ago.

  • Author
  • #92219

    Points: 0
    Rank: Member

    I have JSON data which I would like to process with Powershell. I can select separate nodes and work with that, but I do not know how can I join several nodes (in case of a goal, I have id_goal which holds ID of a player name from roster (Team1 or Team2). Can some guru take a look and help me?

    I am able to pull out as a Out-Gridview a list of goals and with -PassTrough I can work with selected data. But I am missing Player Name (I just pull his ID). How would you join this "tables"? This is the JSON data: http://textuploader.com/dmwbf

    this is the half working code:

    $MatchInfo = Invoke-WebRequest $request | ConvertFrom-Json

    $Competition_id = $MatchInfo.competition.id_competition


    $GoalsTable = @()
    foreach ($record in $Goals)
    $GoalsRecord = @{}
    if($record.id_team -eq $MatchInfo.team1.id_team){
    $PlayerName=$MatchInfo.team1.roster | select first_name, last_name | where {$MatchInfo.team1.roster.id_player -eq $record.goal }
    $GoalsRecord.PlayerName = $PlayerName

    if($record.id_team -eq $MatchInfo.team2.id_team){
    $PlayerName=$MatchInfo.team1.roster | select first_name, last_name | where {$record.goal -eq $MatchInfo.team1.roster.id_player }
    $GoalsRecord.PlayerName = $PlayerName


    $GoalsTable += ([PSCustomObject]$GoalsRecord)


    $GoalsTable | Sort score -Descending | Out-GridView -PassThru

  • #92258

    Points: 157
    Helping Hand
    Rank: Participant

    Can you post sample data for $MatchInfo after line 1?

The topic ‘Json & Powershell query Select’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort