Class ParseJSONResultsPlugin

Parses JSON strings in query results into JSON objects.

This plugin can be useful with dialects that don't automatically parse JSON into objects and arrays but return JSON strings instead.

const db = new Kysely<DB>({
plugins: [new ParseJSONResultsPlugin()]


  • ParseJSONResultsPlugin




  • This is called for each query before it is executed. You can modify the query by transforming its OperationNode tree provided in args.node and returning the transformed tree. You'd usually want to use an OperationNodeTransformer for this.

    If you need to pass some query-related data between this method and transformResult you can use a WeakMap with args.queryId as the key:

    const plugin = {
    data: new WeakMap<QueryId, SomeData>(),

    transformQuery(args: PluginTransformQueryArgs): RootOperationNode {, something)
    return args.node

    transformResult(args: PluginTransformResultArgs): QueryResult<UnknownRow> {
    const data =
    return args.result

    You should use a WeakMap instead of a Map or some other strong references because transformQuery is not always matched by a call to transformResult which would leave orphaned items in the map and cause a memory leak.


    Returns RootOperationNode

Generated using TypeDoc