Extend or override the standard RPC JSON serializer.
Scanned 9/12/2026
Install to Claude Code
npx -y skills add ali-master/skills --skill orpc-rpc-json-serializer --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Orpc Rpc Json Serializer?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/ali-master-orpc-rpc-json-serializer)More formats (shields.io, HTML) on the badges page.
---
name: oRPC RPC JSON Serializer
description: Extend or override the standard RPC JSON serializer.
license: MIT
metadata:
author: Ali Torki
homepage: https://github.com/ali-master
version: "1.0.0"
---
# RPC JSON Serializer
Handles JSON payloads for the [RPC Protocol](/docs/advanced/rpc-protocol) and supports [native data types](/docs/rpc-handler#supported-data-types).
## Extending Native Data Types
1. **Define Your Custom Serializer:**
```ts
import type { StandardRPCCustomJsonSerializer } from '@orpc/client/standard'
export class User {
constructor(
public readonly id: string,
public readonly name: string,
public readonly email: string,
public readonly age: number,
) {}
toJSON() {
return { id: this.id, name: this.name, email: this.email, age: this.age }
}
}
export const userSerializer: StandardRPCCustomJsonSerializer = {
type: 21,
condition: data => data instanceof User,
serialize: data => data.toJSON(),
deserialize: data => new User(data.id, data.name, data.email, data.age),
}
```
> Ensure `type` is unique and greater than `20` to avoid conflicts with built-in types.
2. **Use Your Custom Serializer:**
```ts
import { RPCHandler } from '@orpc/server/fetch'
import { RPCLink } from '@orpc/client/fetch'
const handler = new RPCHandler(router, {
customJsonSerializers: [userSerializer],
})
const link = new RPCLink({
url: 'https://example.com/rpc',
customJsonSerializers: [userSerializer],
})
```
## Overriding Built-in Types
Match `type` with [built-in types](/docs/advanced/rpc-protocol#supported-types).
Example: oRPC ignores `undefined` in objects. To override:
```ts
export const undefinedSerializer: StandardRPCCustomJsonSerializer = {
type: 3, // Match built-in undefined type
condition: data => data === undefined,
serialize: data => null,
deserialize: data => undefined,
}
```
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!