JSON Array to MySql Insert Query
Today, I wish to let you know a small trick to create a MySql query from JSON Array. Developers who is working on core language without using framework they generally face problem to insert a large data into databases which is present in the JSON Array format.
Here, I am depicting a way through which you can make your work easy. As for the example I am going to take a JSON Array of Country and Currency which is required to be stored in MySql database.
Now, We are going to create a function which take 3 parameter in my case. First parameter is for Table name , Second Parameter for Column Name and Third parameter for JSON Array .
Now, Call this function to get a String which is used to Insert Data into MySql Database.
And In last you will get a String which is used as MySql Query
It’s just an basic idea to create a dynamic MySql query using this Small and Easy function. The above piece of code is written into JavaScript. You can code this logic into any language according to your need.