huridocs/uwazi

View on GitHub
app/shared/JSONUtils.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
export default {
  parseNested(object) {
    if (typeof object !== 'object') {
      return object;
    }
    const result = { ...object };
    Object.keys(object).forEach(index => {
      try {
        result[index] = JSON.parse(object[index]);
      } catch (e) {
        result[index] = object[index];
      }
    });
    return result;
  },
};