-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JSON as an export option #173
base: main
Are you sure you want to change the base?
Conversation
… for each file type
@invisal please help to review it again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for delay review. Because there are some refactoring. This need to slightly change. You can follow the sample code of Copy As JSON
export default function saveStructuredTextFile( | ||
fileName: string, | ||
type: SupportedStructuredFileType, | ||
records: object[] | ||
) { | ||
|
||
const serializers = { | ||
json: jsonSerializer, | ||
} | ||
|
||
fs.writeFileSync(fileName, serializers[type](records)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is overkill. We only need a single function that able to write text file.
@@ -213,6 +222,18 @@ export default function ExportModal({ data, onClose }: ExportModalProps) { | |||
console.error(e); | |||
setStage('ERROR'); | |||
}); | |||
} else if (format === "json") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can follow this for JSON
We just need to do
jsonString = // can follow the above code;
window.electron.saveTextFile(fileName, jsonString);
This will export as an unformatted JSON file using
JSON.stringify(data)