-
-
Notifications
You must be signed in to change notification settings - Fork 316
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
The CLI will now output a quoted string with escape characters instead of raw json like the previous version. #711
Comments
We're glad you find this project helpful. We'll try to address this issue ASAP. You can vist https://solothought.com to know recent features. Don't forget to star this repo. |
I tested in my local environment and it is working fine.
I'm not sure if it is OS specific issue. Can you please recheck with v5 and confirm me back? |
@amitguptagwl I'm using this purely as a CLI tool for my Jenkins pipeline to read the pom.xml. I tried on both Linux via a Jenkins pipeline and MacOS. Here is the full script to recreate including the install scripts. #!/bin/bash
# If you already have fxparser installed uninstall it
npm uninstall -g --silent fast-xml-parser
# Install via npm
npm install -g --silent fast-xml-parser
echo '<xml><item>test</item></xml>' | fxparser 2> /dev/null When I save that into Output: ./fxparser-issue.sh
"{\n \"xml\": {\n \"item\": \"test\"\n }\n}" If I update the install command to use the previous version like this It looks like in the code const callback = function(xmlData) {
let output = '';
if (validate) {
const parser = new XMLParser(options);
output = parser.parse(xmlData,validate);
} else if (validateOnly) {
output = XMLValidator.validate(xmlData);
process.exitCode = output === true ? 0 : 1;
} else {
const parser = new XMLParser(options);
output = JSON.stringify(parser.parse(xmlData,validate), null, 4);
}
if (outputFileName) {
writeToFile(outputFileName, output);
} else {
console.log(JSON.stringify(output, null, 2));
}
}; When |
I updated my pr (#712) to fully address the issue. The issue only occurs when you call |
let me check throughly. We can't avoid JSON parse. |
The update in the #712 will still call parse and stringify, it will just do it one time in all cases as expected. |
Description
The CLI now outputs a string instead of valid JSON, like the previous versions did.
Examples:
version 4.5.1
version 4.5.2
Input
<xml><item>test</item></xml>
Code
Output
"{\n \"xml\": {\n \"item\": \"test\"\n }\n}"
expected data
{ "xml": { "item": "test" } }
Would you like to work on this issue?
I cannot commit much time but I have opened a PR that fixes it locally for me. I'm not familiar enough with the project to add unit tests that will ensure this doesn't become a future regression.
Bookmark this repository for further updates. Visit SoloThought to know about recent features.
The text was updated successfully, but these errors were encountered: