How to access a property whose name consists of an asterisk in PowerShell?

Viewed 153

The wikipedia API returns JSON that contains an element with the name *. How can I access such a property in PowerShell?

Example:

$json = Invoke-RestMethod -Method Get -Uri 'https://en.wikipedia.org/w/api.php?action=parse&pageid=10000&prop=wikitext&format=json'
$json.parse.wikitext.* # fails

Error: "Missing property name after reference operator." So the asterisk is not recognized as a property name.

JSON excerpt:

{ 
   "parse": { 
      "title": "Eiffel",
      "pageid": 10000,
      "wikitext": { 
         "*": "{{Wiktionary|Eiffel}}\n'''Eiffel''' ..."
      }
   }
}
1 Answers

Put it in quotation marks:

$json.parse.wikitext."*"
Related