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

Add Example of Serialization/Deserialization for CSV #2749

Open
LeviButcher opened this issue Feb 13, 2023 · 3 comments
Open

Add Example of Serialization/Deserialization for CSV #2749

LeviButcher opened this issue Feb 13, 2023 · 3 comments
Assignees
Labels

Comments

@LeviButcher
Copy link

Short summary (3-5 sentences) describing the issue.

Currently, there is no up to date example of how to implement a Custom Formatter to return both CSV Response and Read a CSV request (Using text/csv with Content-Type and Accept headers). My use case for needing this example is for allowing batch updates with a CSV file across multiple entity types. This could be elegantly solved if it was possible to accept a request of text/csv and the server automatically de-serialized it and applied the data to a patch endpoint.

Any guidelines would be appreciated and I'm more then willing to write up the example and place over here: https://github.com/OData/ODataSamples

Assemblies affected

*Which assemblies and versions are known to be affected e.g. OData WebApi lib 6.1.0

Most recent Odata Versions.

@xuzhg xuzhg self-assigned this Feb 28, 2023
@xuzhg
Copy link
Member

xuzhg commented Mar 6, 2023

@LeviButcher I am working on a demo.
I have a question about CVS for you or the community. What's your expectation output about the complex property or collection property?

@xuzhg
Copy link
Member

xuzhg commented Mar 10, 2023

@xuzhg xuzhg added fixed and removed in-progress labels Mar 10, 2023
@xuzhg xuzhg closed this as completed Mar 14, 2023
@xuzhg xuzhg reopened this Mar 14, 2023
@sharshi
Copy link

sharshi commented Jan 17, 2025

@xuzhg great work on the article, It's the only working implementation I was able to find that got this far in solving this.

I'm exploring options for dealing with the navigation property, I see you parse it into one 'cell'. I think there are two general approaches to take for navigation properties:

{
  "name": "John Doe",
  "age": 30,
  "address": {
    "street": "123 Main St",
    "city": "Anytown",
    "zipCode": "12345"
  },
  "hobbies": ["reading", "traveling", "swimming"],
  "contacts": [
    {
      "type": "email",
      "value": "[email protected]"
    },
    {
      "type": "phone",
      "value": "555-1234"
    }
  ]
}
  1. columns could be root level: name, age, address, hobbies, contacts and the arrays/objects are parsed as json and take of one cell
    • PRO: one row per result
    • CON: json in a csv is not standard
    • CON: good luck using the data
  2. columns could be dot notation: name, age, address.street, address.city, address.zipCode, hobbies, contacts.type, contacts.value:
    • PRO: Data is denormalized
    • CON: The number of rows will grow with every array, and exponentially with the combination of multiple arrays.
name age address.street address.city address.zipCode hobbies contacts.type contacts.value
John Doe 30 123 Main St Anytown 12345 reading email [email protected]
John Doe 30 123 Main St Anytown 12345 reading phone 555-1234
John Doe 30 123 Main St Anytown 12345 traveling email [email protected]
John Doe 30 123 Main St Anytown 12345 traveling phone 555-1234
John Doe 30 123 Main St Anytown 12345 swimming email [email protected]
John Doe 30 123 Main St Anytown 12345 swimming phone 555-1234

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

No branches or pull requests

3 participants