Skip to content

Decodes a value if it is json else defaults to an input value.

Notifications You must be signed in to change notification settings

anno-ai/js-decode-if-json

Repository files navigation

Node.js Unit Tests

js-decode-if-json

A helper method that decodes a value if json else defaults to an input value.

const test = decodeIfJson('Hello World', { defaultValue: 'Hello World Default' });
console.log(test); // { defaultValue: 'Hello World Default' }