-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
feat: add XML to JSON operation #1631
base: master
Are you sure you want to change the base?
Conversation
e48a3e8
to
6347f01
Compare
@@ -168,6 +168,7 @@ | |||
"ssdeep.js": "0.0.3", | |||
"stream-browserify": "^3.0.0", | |||
"tesseract.js": "3.0.3", | |||
"timers": "^0.1.1", |
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.
Is this used?
run(input, args) { | ||
let result; | ||
try { | ||
xml2js.parseString(input, {}, (e, r) => result = JSON.stringify(r)); |
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.
You're not using the error result in the callback. I assume xml2js uses that rather than throwing an error, and it's going to include useful parser errors.
run(input, args) { | ||
let result; | ||
try { | ||
xml2js.parseString(input, {}, (e, r) => result = JSON.stringify(r)); |
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.
You're taking the return value, encoding it into JSON and then parsing it back again. That seems unnecessary,
run(input, args) { | ||
let result; | ||
try { | ||
xml2js.parseString(input, {}, (e, r) => result = JSON.stringify(r)); |
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.
There's a callback here: is xml2js synchronous or asynchronous? It might be safer to return a Promise that handles the callback result.
Hey! This pull request has gotten rather old and that's our fault. This project stopped being actively maintained for a while and it looks like your pull request has started to gather dust. Would you be able to update your branch to the latest version of CyberChef and we'll give it a review? |
Resolves #1607.
Add new "XML to JSON" operation.