I have the following json message, am getting results, am getting 1 team instead of all, i want to get all teams

teams are enclosed by curly braces in

"teams":[ {}, #team {} # another team ],

{ "sports": [ { "id": "600", "leagues": [ { "id": "700", "teams": [ { "team": { "id": "331", "name": "Brighton & Hove Albion", "isAllStar": false, "logos": [ { "alt": "", "rel": [ "full", "default" ], "width": 500, "height": 500 }, { "alt": "", "rel": [ "full", "dark" ], "width": 500, "height": 500 } ], "links": [ { "language": "en-US", "rel": [ "clubhouse", "desktop", "team" ], "text": "Clubhouse" }, { "language": "en-US", "rel": [ "stats", "desktop", "team" ], "text": "Stats" }, { "language": "en-US", "rel": [ "schedule", "desktop", "team" ], "text": "Fixtures" } ] } }, { "team": { "id": "380", "name": "Wolverhampton Wanderers", "isAllStar": false, "logos": [ { "alt": "", "rel": [ "full", "default" ], "width": 500, "height": 500 }, { "alt": "", "rel": [ "full", "dark" ], "width": 500, "height": 500 } ], "links": [ { "language": "en-US", "rel": [ "clubhouse", "desktop", "team" ], "text": "Clubhouse" }, { "language": "en-US", "rel": [ "stats", "desktop", "team" ], "text": "Stats" }, { "language": "en-US", "rel": [ "schedule", "desktop", "team" ], "text": "Fixtures" } ] } } ], "year": 2025, "season": { "year": 2025, "displayName": "2025" } } ] } ] }

this is my code

for my $match (@{$parse_json->{sports}}) { my $teamname = $match->{leagues}[0]{teams}[0]{team}{name}; $Response_tmlist .= $teamname; print $Response_tmlist; }

In reply to parse out json message by frank1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.