fix : parsing issue is fixed in the table view (#2693)

* fix: parsing is updated
This commit is contained in:
Palash Gupta 2023-05-15 18:04:58 +05:30 committed by GitHub
parent df0502726d
commit c7f09354f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -89,7 +89,7 @@ function TableView({ logData }: TableViewProps): JSX.Element | null {
if (!isEmpty(parsedBody)) {
return (
<Editor
value={JSON.stringify(parsedBody, null, 2)}
value={JSON.stringify(parsedBody, null, 2).replace(/\\n/g, '\n')}
readOnly
height="70vh"
options={{

View File

@ -4,6 +4,15 @@ export const recursiveParseJSON = (obj: string): Record<string, unknown> => {
if (typeof value === 'string') {
return recursiveParseJSON(value);
}
if (typeof value === 'object') {
Object.entries(value).forEach(([key, val]) => {
if (typeof val === 'string') {
value[key] = val.trim();
} else if (typeof val === 'object') {
value[key] = recursiveParseJSON(JSON.stringify(val));
}
});
}
return value;
} catch (e) {
return {};