本文へ移動
Senri

JSON の整形

prettyJSON() で、?pretty を付けたときに JSON を整形する

import { ,  } from "@senrijs/senri";

const  = ();

.(());
.("/users", () => [{ : 1, : "alice" }]);
curl "http://localhost:3927/users?pretty"
# [
#   {
#     "id": 1,
#     "name": "alice"
#   }
# ]
  • クエリに pretty があるときだけ整形します
  • 1 MiB を超える本文と、ストリームは整形しません
  • compress() と etag() のあとに登録します

オプション

名前

型

このページの内容