本页还没有译文
本页 12 段还没译成日本語,下面显示的是英文原文。Pretty JSON Middleware
还没翻译译自英文(hono.dev)本页 12 段都还没译
Pretty JSON Middleware
Pretty JSON middleware enables "JSON pretty print" for JSON response body.
Adding ?pretty to url query param, the JSON strings are prettified.
// GET /
{"project":{"name":"Hono","repository":"https://github.com/honojs/hono"}}will be:
// GET /?pretty
{
"project": {
"name": "Hono",
"repository": "https://github.com/honojs/hono"
}
}Import
import { Hono } from 'hono'
import { prettyJSON } from 'hono/pretty-json'Usage
const app = new Hono()
app.use(prettyJSON()) // With options: prettyJSON({ space: 4 })
app.get('/', (c) => {
return c.json({ message: 'Hono!' })
})Options
optional space: number
Number of spaces for indentation. The default is 2.
optional query: string
The name of the query string for applying. The default is pretty.
optional force: boolean
When set to true, JSON responses are always prettified regardless of the query parameter. The default is false.
AI 翻译查看英文原文