Spaces:
Sleeping
Sleeping
File size: 451 Bytes
7aec436 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
const unstructure = (messages) => {
for (const key of Object.keys(messages)) {
const value = messages[key];
if (typeof value === 'object') {
if (value.string) {
messages[key] = value.string;
} else {
unstructure(value);
}
}
}
return messages;
};
module.exports = function (source) {
const parsed = JSON.parse(source);
unstructure(parsed);
return JSON.stringify(parsed);
};
|