blob: c6f6c77487741a365d2b8c8b668d293d0e75a384 [file] [log] [blame]
'use strict';
/**
* Converts a JSON string to object
* @param jsonString
* @param source
*/
const jsonStringToObject = (jsonString, source = {} ) => {
const s = jsonString.replace(/'/g, '"');
try {
return Object.assign(source, JSON.parse(s));
}
catch (e) {
throw new Error(`Failed to parse json string: ${s}. Error: ${e.message}`);
}
};
export { jsonStringToObject };