Skip to content
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

PapaParse unparser is not flattening the input object #245

Closed
tejasatara opened this issue Jul 30, 2015 · 3 comments
Closed

PapaParse unparser is not flattening the input object #245

tejasatara opened this issue Jul 30, 2015 · 3 comments

Comments

@tejasatara
Copy link

Hi,

I am using Papa unparser in my project. All my input is highly dynamic and unpredictable (nested objects and arrays).
When I provide a input which has nested objects the unparser just writes [object Object] instead of flattening the object.

Example :

{
    "_index": "documents",
    "_type": "message",
    "_id": "4868ecf0-01ba-3f1a-b6f5-e7eb0c9c630f",
    "_score": null,
    "_source": {
        "fileName": "dynamically-loading-controllers-and-views-with-angularjs-and-requirejs",
        "header": {
            "artifactModifiedBy": "ops",
            "source": "internal",
            "artifactCreatedDate": 1438247629068,
            "uuid": "250efb1c-57e7-44f7-a02a-eee1bef9dc48",
            "type": "message",
            "date": 1438247629232,
            "relationships": {
                "parent": "a6d84953-8f0a-41f4-8fb5-756b5f65ea1b"
            },
            "artifactModifiedDate": 1438247629232,
            "artifactUUID": "4868ecf0-01ba-3f1a-b6f5-e7eb0c9c630f"
        },
        "mimeType": "text/html; charset=utf-8",
        "size": 88707
    },
    "sort": [
        1438247629232
    ]
}

The _source field just written as [object Object].

@tejasatara tejasatara changed the title Papa Unparse is not flattening the input object PapaParse unparser is not flattening the input object Jul 30, 2015
@mholt
Copy link
Owner

mholt commented Jul 30, 2015

Printing any object as a string results in [object Object] - you need to traverse the data structure to print what you're looking for, or use console.log().

@mholt mholt closed this as completed Jul 30, 2015
@tejasatara
Copy link
Author

Thanks for the update. I have written a flatten script which does the traversing, it would've been great if it was a part of parser itself.

@leblancmeneses
Copy link

following worked for me
https://www.npmjs.com/package/flat

const csv = Papa.unparse(this.itemSource.map(flatten));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants