[Python] jinja2: convert string to dict object?

Discussão em 'Python' iniciado por Stack, Junho 6, 2025.

  1. Stack

    Stack Membro Participativo

    I have a json string stored in the database and when this is pulled out and shown on the template it is a string. I want to convert this into a dict object so I can access the contents directly.

    string = "{'a':1, 'b':3}"

    {{ obj }} ---> string "{'a':1, 'b':3}"

    {{ obj.b }} ---> I want to access it like an object.

    Continue reading...

Compartilhe esta Página