Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have requirement to convert csv to json dynamically ...I have job where the csv file has to be converted to json to load through api ..The same requirement has to be done for different csv file ..So is there any way to create as joblet dynamically or through routine ?
This is an almost impossible requirement. If you look at a CSV file, there is no default JSON structure that will best suit it. Which are parent objects? Which are child objects? Which are arrays? Now you could possibly come up with an optimal structure by analysing data sets. But how do you know that your optimal structure will match your API requirements?
You will need to define your CSV data, identify the JSON formats that your APIs support and then match the data to the API JSON structure. You can get your data to find the correct job to convert the data appropriately, but you will find it very hard to dynamically create JSON from a single job I'm afraid.
I would say this was possible - with a bit of Java coding, IF your CSV file has a header row with the column names.
It'd be a 2 step process:
It's quite a bit of messing around, but it would work - it does allow you to extract it out fully into a generic routine where you can pass in things like the delimiter as well to allow it to process files with different delimiters