Stale question, sure, but it's got a much better answer nowadays.
There's a simple version, where you don't care about the top-level key, only the top-level value:
select json_path_query(
doc,
'$.* ? (@.players[*] == $player)',
'{"player": "eli"}'
) from TEAMS
If you want the top-level key, I don't have a good suggestion that doesn't involve conversion and/or expansion.
select json_path_query(
(team).value,
'$ ? (@.players[*] == $player)',
'{"player": "eli"}'
) from (
select json_each(doc) as team from TEAMS
) schedule
As this is an XY problem, most definitely, you might be interested in knowing whether eli's brother, "ERROR:ROOT", played that day too. You can always pass an array of values in for that third argument to json_path_query(), like so:
select json_path_query(
doc,
'$.* ? (@.players[*] == $player[*])',
'{"player": ["eli","ERROR:ROOT"]}'
) from TEAMS
Oh! That raises a really good possibility. Say you have a team, and you want to know what other days any of those players are up. You might do something like so:
select json_path_query(
doc,
'$.* ? (@.players[*] = $players[*])',
'{"num":3, "players": ["a", "eli", "x"], "color":"blue"'
) from TEAMS
If you want to know more, the PostgreSQL docs are expansive but fantastically detailed. There are tons of great examples in there, both at the page on JSON datatype and JSONpath, but also the page on JSON functions.
The JSON datatype: https://www.postgresql.org/docs/13/datatype-json.html
JSON functions: https://www.postgresql.org/docs/13/functions-json.html