how to export datas to json file from mysql
I have datas in mysql I want to move them to a json file. How can I do that?
7 Replies
I think you don't even need a C# for this. Is there any MySQL extension that helps writing data into a file?
or you can do it manually by using Dapper / EF Core and stringify as JSON into a file
I found this
https://stackoverflow.com/questions/41758870/how-to-convert-result-table-to-json-array-in-mysql
Stack Overflow
How to convert result table to JSON array in MySQL
I'd like to convert result table to JSON array in MySQL using preferably only plain MySQL commands. For example with query
SELECT name, phone FROM person;
| name | phone |
| Jack | 12345 |
| John |
I need to write as a service so I can do it from controller
that's my task
I see
so as I told, use Dapper or EF Core to get list of your items and then stringify it as json
can't use both. only ado and linq allowed
You should be able to do this by now. Just break it down.
Query data from database, save in memory as objects
serialize objects to json
write to file
yh I managed to do it. I used DTO and serialized it