A bug in parsing
See original GitHub issueconst { Parser,transforms: { unwind } } = require('json2csv');
const myCars = [
{
"carModel": "Porsche",
"price": 30000,
"items": [
{
"name": "airbag",
"items": [
{
"position": "left",
"color": "white"
}, {
"position": "right",
"color": "gray"
}
]
}, {
"name": "dashboard",
"items": [
{
"position": "left",
"color": "gray"
}, {
"position": "right",
"color": "black"
}
]
}
]
}
];
const fields = ['carModel', 'price', 'items.name', 'items.color', 'items.items.position', 'items.items.color'];
const transforms = [unwind(['items', 'items.items'])];
const json2csvParser = new Parser({ fields, transforms });
const csv = json2csvParser.parse(myCars);
console.log(csv);
output:
"carModel","price","items.name","items.color","items.items.position","items.items.color"
"Porsche",30000,"airbag",,"left","white"
"Porsche",30000,"airbag",,"right","gray"
"Porsche",30000,"dashboard",,"left","gray"
"Porsche",30000,"dashboard",,"right","black"
But if I remove one item from myCars[0].items[]
const { Parser,transforms: { unwind } } = require('json2csv');
const myCars = [
{
"carModel": "Porsche",
"price": 30000,
"items": [
{
"name": "airbag",
"items": [
{
"position": "left",
"color": "white"
}, {
"position": "right",
"color": "gray"
}
]
}
]
}
];
const fields = ['carModel', 'price', 'items.name', 'items.color', 'items.items.position', 'items.items.color'];
const transforms = [unwind(['items', 'items.items'])];
const json2csvParser = new Parser({ fields, transforms });
const csv = json2csvParser.parse(myCars);
console.log(csv);
output:
"carModel","price","items.name","items.color","items.items.position","items.items.color"
"Porsche",30000,"airbag",,,
Not printing “items.items.position”,“items.items.color”
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
Exploiting Parsing Bugs - Black Hat
Exploiting Parsing Bugs. Greg Hoglund. Cenzic, Inc. Page 2. What is parsing? Page 3. State Machines. SYSTEM A. SYSTEM B. GET /..\/..\/..\/..\etc\passwd ...
Read more >Parsing, Parsing, Parsing | Groove Blog - Groove HQ
Parsing problems reveal themselves in the UI two ways, either by sending blank or empty replies in the place of a customer's response,...
Read more >Bug in parsing for some multi-page Documents, #1 - GitHub
When parsing some multi-page outputs, there's a bug in the trp.py file. Due to which the keys in the blockmap at line 142...
Read more >URL Parsing-Library Bugs Allow DoS, RCE, Spoofing & More
URL parsing is the process of breaking down a web address into its underlying components, in order to correctly route traffic across different ......
Read more >Question:Bugs in parsing? - MaplePrimes
Hello there! Maple 2016.1 sometimes gets crasy about parsing input strings. I managed to capture this behaviour in the attached file.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Already released 😄
Not sure if it’s worth doing a release just for a small documentation fix.
But I don’t think that we will have anything else to release anytime soon.