by daurnimator · 12y ago · 0 comments
wat.
At the risk of providing something useful to the discussion though, I'd like to point out the excellent tool jq: http://stedolan.github.io/jq/
Here's how to use it for the conversion in the article:
jq '.places[] | [.n,.i,.p[0],.p[1],.s] | map(tostring) | join(",")' hotelMarkers.js
(after editing hotelMarkers.js into a proper json file)1. http://en.wikipedia.org/wiki/Comma-separated_values#Basic_ru...
Using the wrong tool for a really easy job can sometimes be faster than the minimal effort of getting the right tool ready.
s/^."n":"(.+)","i":"(.+)","p":\[([\d\.\-]+),([\d\.\-]+)],"s":"(\w+)","c":"(.+)".$/\1,\2,\3,\4,\5/;
insert into my_table values ($$ json_goes_here $$);
Works for all stringy things.