MySQL: Upload a JSON file into a table programmatically

Hi
Does anymore know about a technique, a tool or set of commands to load a JSON file into a mysql table. Please, note fields will match with the JSON structure.
I know I can do it in MySQL Workbench, but I want to automate the process.

Thanks
Omer-PitouAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
James BilousConnect With a Mentor Software EngineerCommented:
I would use the org.json.CDL library:


https://github.com/stleary/JSON-java
0
 
James BilousConnect With a Mentor Software EngineerCommented:
This is a common task called data "marshalling". Essentially, what you'll want to do is write a java program that takes the JSON from in memory, connects to a database using JDBC (or some other database connection API), and loops through your JSON while inserting the data as rows in your database. Here is a good article on the process:

http://www.codeproject.com/Articles/1087995/Inserting-JSON-Text-into-SQL-Server-Table
0
 
Omer-PitouAuthor Commented:
Thanks James,
What I am avoiding is to loop through these rows.
I think I will convert it to CSV, and load it with MySQL LOAD INFILE
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
James BilousSoftware EngineerCommented:
In that case there are online converters that will get you from json to csv that you can fin pretty readily via Google search.
0
 
Omer-PitouAuthor Commented:
Do you know any 3rd party library that I can embed into the app
0
 
James BilousSoftware EngineerCommented:
What exactly are you doing? You didn't really give a lot of context to your problem. You're making an android app that receives JSON and you want to put it into a database by converting it to CSV first? This seems to be the most round about and difficult way to do this. Why not just use all the tools and APIs available from the Android Developmen toolkit that were made for this exact purpose?
0
 
Omer-PitouAuthor Commented:
I am not developing an Android app.
It is a SE app which will in a local network.
Some of the data need to be transferred to a remote database (web server) to serve the web dashboard application. This will be done through a web service.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.