Files
threshold-ui/ui/desktop/electron-app/src/utils/jsonify.js
T

16 lines
300 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
// Convert to json
const jsonify = (data) => {
if (typeof data !== 'string') data = JSON.stringify(data);
try {
return JSON.parse(data);
} catch (e) {
// Ignore parse errors
}
};
module.exports = jsonify;