Creates a JSON response.

  • Parameters

    • data: unknown

      The data to be serialized as JSON.

    • options: ResponseInit = {}

      Optional response initialization options.

    Returns Response

    A Response object with the specified JSON content.

    Example usage:

    import { start, router, json } from "@pulsar-http/core";

    const routes = [
    router.get("/api/users", async () => json({ users: [] })),
    ];

    start({ routes });

    In this example, the response will have a JSON body with the content { "users": [] }.