I have the following code:
import json
domain="abc.com"
rawlog = json.loads(
f'{"domain": ${domain}}')
print(rawlog["domain"])
Which gives me:
Traceback (most recent call last):
File "<string>", line 6, in <module>
ValueError: Invalid format specifier
>
The question is, what is the cause and if I can have fstring in Json? I'm using the newest Python: python3 --version shows Python 3.10.4.
I also tried:
import json
domain="abc.com"
rawlog = json.loads('{"domain": f'{domain}'}')
print(rawlog["domain"])
but it gives:
File "<string>", line 5
rawlog = json.loads('{"domain": f'domain'}')
^
SyntaxError: invalid syntax