prisma-json-field-api-serialization

Convert Prisma Json, Decimal, BigInt, DateTime, and Bytes string fields to native types.

2|Updated May 10, 2026
One-click install
npx skills add https://github.com/freedomw1987/tree_monstor --skill prisma-json-field-api-serialization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prisma-json-field-api-serialization
Source: https://github.com/freedomw1987/tree_monstor/tree/main/skills/debugging/prisma-json-field-api-serialization
Command: npx skills add https://github.com/freedomw1987/tree_monstor --skill prisma-json-field-api-serialization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prisma serializes Json, Decimal, BigInt, DateTime, and Bytes fields as strings over REST APIs, causing runtime errors like type mismatches, failed test assertions, and method crashes when consumer code expects the native JavaScript type for these fields.

Core Features & Use Cases

  • Per-type conversion patterns: Provides explicit, safe coercion logic for each affected Prisma field type to resolve common errors like "options.map is not a function" for Json fields, Decimal/BigInt equality mismatches, and Date method crashes.
  • Multi-context support: Includes fixes for TypeScript frontend code, E2E test suites (Playwright/API tests), and API response normalization layers.
  • Prevention guidance: Offers best practices for API design and test writing to avoid these serialization issues entirely, plus a verification recipe to inspect actual API response types.
  • Use case example: If your E2E test fails because a Prisma Decimal field returns "2.5" as a string instead of the number 2.5, this skill provides the correct Number() coercion pattern to fix the assertion without losing precision.

Quick Start

Apply the correct per-field conversion patterns to fix Prisma REST serialization type mismatches for Json, Decimal, BigInt, DateTime, and Bytes fields in your API responses and test code.

Frequently Asked Questions about prisma-json-field-api-serialization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my Prisma Decimal field return a string instead of a number over my REST API?

Prisma serializes Decimal fields as strings over REST APIs to prevent precision loss, causing type mismatches when frontend code expects native JavaScript numbers. Applying explicit Number() coercion patterns in your API response normalization layer resolves this without losing precision.

How do I fix the "options.map is not a function" error for Prisma Json fields in TypeScript?

To fix the "options.map is not a function" error for Prisma Json fields, you must safely coerce the serialized string back into a native JavaScript object or array. This skill provides explicit per-type conversion patterns to resolve these runtime crashes in TypeScript frontend code.

What is the best way to handle Prisma BigInt serialization mismatches in E2E test suites?

The best way to handle Prisma BigInt serialization mismatches in E2E testing is to apply explicit, safe coercion logic within your test assertions. This prevents silent comparison failures when the REST API returns the BigInt as a string instead of its native type.

Does this Skill support fixing DateTime field serialization for Playwright API tests?

Yes, this Skill supports fixing DateTime field serialization for Playwright API tests. It includes multi-context support for E2E test suites to prevent Date method crashes by correctly coercing serialized strings back to native Date objects.

How to prevent silent comparison failures for non-primitive Prisma field types over HTTP?

To prevent silent comparison failures for non-primitive Prisma field types over HTTP, implement API response normalization layers with explicit per-type conversion logic. This skill also offers prevention guidance and verification recipes for API design and test writing.