Skip to content

Commit f5b54a1

Browse files
committed
feat: fixing the json does not render properly
1 parent 770197a commit f5b54a1

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/renderer/datatype/JsonType.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import BaseType from './BaseType';
22
import deepEqual from 'deep-equal';
33

4-
export default class JsonType implements BaseType<object> {
5-
protected value?: object | null;
4+
export default class JsonType implements BaseType<object | string> {
5+
protected value?: object | string | null;
66

77
constructor(value?: object | string | null) {
88
if (typeof value === 'object') this.value = value;
99
else if (typeof value === 'string') {
1010
try {
1111
this.value = JSON.parse(value);
1212
} catch {
13-
this.value = undefined;
13+
this.value = value;
1414
}
1515
} else {
1616
this.value = value;
@@ -69,7 +69,7 @@ export default class JsonType implements BaseType<object> {
6969
return stringValue.includes(search);
7070
}
7171

72-
getValue(): object | null | undefined {
72+
getValue(): object| string | null | undefined {
7373
return this.value;
7474
}
7575
}

src/renderer/screens/DatabaseScreen/QueryResultViewer/TableCell/TableCellJson.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,12 @@ function TableCellJsonEditor({
6666
);
6767
}
6868

69-
function TableCellJsonContent({ value }: TableEditableContentProps) {
69+
function TableCellJsonContent({ value }: TableEditableContentProps<JsonType>) {
7070
return (
7171
<TableCellContent
72-
value={value}
72+
value={value.toNullableString()}
7373
badge="json"
7474
mono
75-
displayString={value ? JSON.stringify(value) : undefined}
7675
/>
7776
);
7877
}
@@ -88,7 +87,7 @@ const TableCellJson = createTableCellType({
8887
return new JsonType(null);
8988
},
9089
onCopy: (value: JsonType) => {
91-
return JSON.stringify(value);
90+
return value.toString();
9291
},
9392
onPaste: (value: string) => {
9493
return { accept: true, value: new JsonType(value) };

0 commit comments

Comments
 (0)