Wednesday, January 14, 2015

JSON to cvs

Today I received a task which is to pull state and area into a cvs file to be used for our database down the road.

My senior taught me a few ways to look for where are the data so I know where to retrieve.

If it is from the server side, during inspect element the console will have logged out the actions.
if it is hard-coded in the HTML in the dropdown selection etc, I should see the data by inspecting the element of the form.
And finally, which is what happened today. The data is in the javascript. Firstly I hit view source so I can view the entire HTML file. From there I search for .js and look for the js file that is triggered to load the information.

I then copied the JSON and went to http://www.convertcsv.com/ to convert the JSON to CSV.

Also, my senior taught me that I should always visit jsonlint.com to validate JSON before attempting to do anything with it.

Credits to my senior.

No comments:

Post a Comment