async-call-rpc

A lightweight JSON RPC client & server

Home > async-call-rpc > JSONEncoderOptions > keepUndefined

JSONEncoderOptions.keepUndefined property

How to handle "undefined" in the result of SuccessResponse.

Signature:

keepUndefined?: false | 'null' | undefined;

Remarks

If you need a full support of encoding undefined, for example, when the result is { field: undefined } and you want to keep it, you need to find another library to do this.

If this is not handled properly, JSON.stringify will emit an invalid JSON-RPC object (fields with undefined value will be omitted).

Options: - "null"(**default**): convert it to null. - false: do not do anything, let it break.