tRPCttRPC
Powered by
DimiD
tRPC•3y ago•
2 replies
Dimi

SuperJSON is wrapping results in type with keys "json" and "meta"

How can I modify the transformer in SuperJSON library to only return the "json" property and ignore the "meta" property during serialization? The current behavior of the library wraps the results in the SuperJSONResult interface, but I want to access only the "json" property after serialization.

interface SuperJSONResult {
    json: JSONValue;
    meta?: {
        values?: MinimisedTree<TypeAnnotation>;
        referentialEqualities?: ReferentialEqualityAnnotations;
    };
}
interface SuperJSONResult {
    json: JSONValue;
    meta?: {
        values?: MinimisedTree<TypeAnnotation>;
        referentialEqualities?: ReferentialEqualityAnnotations;
    };
}


This is my current code
const t = initTRPC.context<inferAsyncReturnType<typeof createContext>>().create({
  transformer: {
    serialize: SuperJSON.serialize,
    deserialize: SuperJSON.deserialize,
  },
});
const t = initTRPC.context<inferAsyncReturnType<typeof createContext>>().create({
  transformer: {
    serialize: SuperJSON.serialize,
    deserialize: SuperJSON.deserialize,
  },
});
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

`useSuspenseQuery` returns unexpected `.json` and `.metadata` (SuperJSON)
canastroCcanastro / ❓-help
10mo ago
type safety with meta
BeanBBean / ❓-help
2y ago
superjson type does not work
Alex / KATT 🐱AAlex / KATT 🐱 / ❓-help
4y ago