mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-24 08:46:19 -04:00
JSON to CSV improvements
This commit is contained in:
parent
c9d9730726
commit
2781640a2a
2 changed files with 115 additions and 30 deletions
|
@ -89,5 +89,71 @@ TestRegister.addTests([
|
|||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: nested JSON",
|
||||
input: JSON.stringify({a: 1, b: {c: 2, d: 3}}),
|
||||
expectedOutput: "a,b.c,b.d\r\n1,2,3\r\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: nested array",
|
||||
input: JSON.stringify({a: 1, b: [2, 3]}),
|
||||
expectedOutput: "a,b.0,b.1\r\n1,2,3\r\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: nested JSON, nested array",
|
||||
input: JSON.stringify({a: 1, b: {c: [2, 3], d: 4}}),
|
||||
expectedOutput: "a,b.c.0,b.c.1,b.d\r\n1,2,3,4\r\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: nested array, nested JSON",
|
||||
input: JSON.stringify({a: 1, b: [{c: 3, d: 4}]}),
|
||||
expectedOutput: "a,b.0.c,b.0.d\r\n1,3,4\r\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: nested array, nested array",
|
||||
input: JSON.stringify({a: 1, b: [[2, 3]]}),
|
||||
expectedOutput: "a,b.0.0,b.0.1\r\n1,2,3\r\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: nested JSON, nested JSON",
|
||||
input: JSON.stringify({a: 1, b: { c: { d: 2, e: 3}}}),
|
||||
expectedOutput: "a,b.c.d,b.c.e\r\n1,2,3\r\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
}
|
||||
]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue