PowerToys
PowerToys copied to clipboard
[Bug fix] Add a format validation step before format conversion.
Summary of the Pull Request
This PR aims to fix the bug #35225 by introducing a new method IsJson to determine if a given text is in JSON format.
The IsJson method is then utilized in the ToJsonFromXmlOrCsvAsync method to optimize the processing logic.
If the text is already in JSON format, it is returned directly without further conversion from XML or CSV.
PR Checklist
- [x] Closes: #35225
- [ ] Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
- [x] Tests: Added/updated and all pass
- [ ] Localization: All end user facing strings can be localized
- [ ] Dev docs: Added/updated
- [ ] New binaries: Added on the required places
- [ ] JSON for signing for new binaries
- [ ] WXS for installer for new binaries and localization folder
- [ ] YML for CI pipeline for new test projects
- [ ] YML for signed pipeline
- [ ] Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx
Detailed Description of the Pull Request / Additional comments
Key Changes:
- Added
System.Text.Jsonnamespace. - Implemented
IsJsonmethod to check if the text is in JSON format. - Updated
ToJsonFromXmlOrCsvAsyncmethod to useIsJsonand return the text directly if it is already JSON.
Validation Steps Performed
Manually tested
Before you merge plese check this similar PR: #34151