/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: d3718666f4c8
 */

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

/**
 * A payload containing arbitrary JSON data.
 *
 * @remarks
 *
 * Used for complete state snapshots or final results.
 */
export type JSONPayloadResponse = {
  /**
   * Discriminator indicating this is a raw JSON payload.
   */
  type: "json";
  /**
   * The JSON-serializable payload value.
   */
  value: any;
};

/** @internal */
export const JSONPayloadResponse$inboundSchema: z.ZodType<
  JSONPayloadResponse,
  unknown
> = z.object({
  type: z.literal("json").default("json"),
  value: z.any(),
});

export function jsonPayloadResponseFromJSON(
  jsonString: string,
): SafeParseResult<JSONPayloadResponse, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => JSONPayloadResponse$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'JSONPayloadResponse' from JSON`,
  );
}
