How do I get the value of a json where the key has "." at the beginning?
$json = '{".expires":"2022-10-13"}' | ConvertFrom-Json
cls
$json..expires #trying to get the value 2022-10-13
Error:
On the line:4 caractere:8
$json..expires
~
You must provide a value expression after the '..' operator.
On the line:4 caractere:8
$json..expires
~~~~~~~
Token 'expires' unexpected in the expression or statement.
CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : ExpectedValueExpression
The code above gives error if I put a colon, is there another way?
CodePudding user response:
You can enclose the property name in quotes.
$json.".expires"