today i'm tryng to stylize my list of audiobooks but for doing so i have to make every object with an aspectRatio (key= value) in my json file but it gives me an error .
if i can't write like this in my json file how can i do it ? thank you in avance
CodePudding user response:
...
"aspectRatio": { "width": 150, "height": 200 },
...
Or if the actual numbers don't matter:
...
"aspectRatio": 0.75,
...
CodePudding user response:
you can't do it, json is a data exchange format, not programable
the work-arround solution is:
import json
json_str = """
{
"expr": "150/200"
}
"""
j = json.loads(json_str)
result = eval(j["expr"])
print(result)
but this may lead to security issue, if some body fill the value of expr as:
rm -rf /
that would be interesting