super csv nested bean

前端 未结 1 532
半阙折子戏
半阙折子戏 2021-01-28 02:31

I have a csv

id,name,description,price,date,name,address
1,SuperCsv,Write csv file,1234.56,28/03/2016,amar,jp nagar

I want to read it and stor

相关标签:
1条回答
  • 2021-01-28 03:03

    SuperCSV is the first parser I have seen that lets you create an object within an object.

    for what you are wanting you can try Apache Commons CSV or openCSV (CSVToBean) to map but to do this you need to have the setters of the inner class (setName, setAddress) in the outer class so the CSVToBean to pick it up. That may or may not work.

    What I normally tell people is to have a plain POJO that has all the fields in the csv - a data transfer object. Let the parser create that then use a utility/builder class convert the plain POJO into the nested POJO you want.

    0 讨论(0)
提交回复
热议问题