mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-22 15:56:16 -04:00
Added support for parsing JSON with number type values. Added support for non-array JSON objects. Added extra tests for JSON to CSV operation.
This commit is contained in:
parent
01f0625d6a
commit
8fa8e34027
3 changed files with 100 additions and 0 deletions
|
@ -51,6 +51,10 @@ class JSONToCSV extends Operation {
|
|||
this.rowDelim = rowDelim;
|
||||
const self = this;
|
||||
|
||||
if (!(input instanceof Array)) {
|
||||
input = [input];
|
||||
}
|
||||
|
||||
try {
|
||||
// If the JSON is an array of arrays, this is easy
|
||||
if (input[0] instanceof Array) {
|
||||
|
@ -89,6 +93,8 @@ class JSONToCSV extends Operation {
|
|||
* @returns {string}
|
||||
*/
|
||||
escapeCellContents(data) {
|
||||
if (typeof data === "number") data = data.toString();
|
||||
|
||||
// Double quotes should be doubled up
|
||||
data = data.replace(/"/g, '""');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue