Coder Social home page Coder Social logo

Comments (2)

mrodrig avatar mrodrig commented on August 18, 2024

Hi @dwarthen-tnn, thanks for reporting this. The error that you're seeing (TypeError: kp.slice is not a function) is because the package doesn't currently support any RegExps in the keys option. As noted in the README, the keys option currently just supports either an array of strings or objects in this format:

{
  "field": string, // required
  "title": string, // optional
  "wildcardMatch": boolean, // optional - default: false
}

If I'm understanding your use case correctly, you're essentially looking for a way to specify a custom title for some keys while still including all of the auto-detected keys in the generated CSV. Is that accurate? If so, I think this should be possible to support by refactoring how the titles are specified. That seems like it's probably the best way to handle this type of use case, and could also be setup to handle the title prefixing for wildcardMatched keys desired in #247 too.

from json-2-csv.

dwarthen-tnn avatar dwarthen-tnn commented on August 18, 2024

Hi @dwarthen-tnn, thanks for reporting this. The error that you're seeing (TypeError: kp.slice is not a function) is because the package doesn't currently support any RegExps in the keys option. As noted in the README, the keys option currently just supports either an array of strings or objects in this format:

I think my confusion arose because VS code was assuring me that RegExp was a valid type for the field property, but today I'm not able to replicate that or find any place in the types definitions where that could have come from.

If I'm understanding your use case correctly, you're essentially looking for a way to specify a custom title for some keys while still including all of the auto-detected keys in the generated CSV. Is that accurate?

Yes, that's essentially it. I've worked around this on my end by changing the titles of those fields in my code before they reach the Converter. Not ideal for my use case but it works OK.

Thank you for your reply!

from json-2-csv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.