简体   繁体   中英

Json to csv conversion in Spring boot

I have a csv structure like this

在此处输入图像描述

and I also have one json response

    [
 {
  "ID"   : "1",
  "Name" : "abc",
  "Mobile" : "123456"
   },
   {
  "ID"   : "2",
  "Name" : "cde",
  "Mobile" : "123345"
   }
   ]

I need the output like this

在此处输入图像描述

If your intention is to convert directly the JSON then that baeldung solution that you were given is good.

Otherwise, the way i see it and based on the info you're giving, you will need to have a representation of that JSON in a java object that will either represent some kind of request coming from somewhere or data you're getting from your database in order to be written on a csv.

Check out these, might be useful: https://www.codejava.net/frameworks/spring-boot/csv-export-example

https://zetcode.com/springboot/csv/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM