Conditions | 5 |
Paths | 4 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | var Slf4j = require('@ama-team/voxengine-sdk').Logger.Slf4j |
||
12 | return function (input) { |
||
13 | if (!input || input === '') { |
||
14 | logger.debug('Provided input is a falsey value, returning empty object') |
||
15 | return {} |
||
16 | } |
||
17 | if (typeof input !== 'string') { |
||
18 | logger.debug('Provided input is not a string, returning object with ' + |
||
19 | 'input as $.customData') |
||
20 | return {customData: input} |
||
21 | } |
||
22 | try { |
||
23 | return JSON.parse(input) |
||
24 | } catch (e) { |
||
25 | logger.warn('Failed to deserialize JSON from {}, returning object ' + |
||
26 | 'with input as $.customData', input) |
||
27 | return {customData: input} |
||
28 | } |
||
29 | } |
||
30 | } |
||
32 |