text block

A multi-line string literal opened and closed by three double quotes, whose common indentation is removed automatically.

In more detail

Text blocks keep JSON fixtures, SQL and example requests readable in code. They are still plain strings: they do not parse or validate JSON. Combine one with the formatted method to fill in values, but use a real serializer such as Jackson for production output.

Example

return """
    {"status": "ready"}
    """;

Related terms

Taught in

References

Certification courses