views:

345

answers:

1

I'm currently looking into methods of implementing server-side caching of roughly 10,000 Google Maps geocoder responses in a J2EE web application. Since Google limits the number of geocoding requests to 15,000 per day, I need a method to store my requests for 24 hours. The requests originate from an XML file that sits on the server, and will eventually be updated daily.

Originally, I was thinking of just adding a little bit of extra information to the XML file where each address is stored (one timestamp in the file, and latitude/longitude values for each address). However, I'm wondering if it might not be considerably faster to store the cached data in a separate file, formatted as JSON. My concerns with this approach is:

  • I'm much more familiar and comfortable working with XML than JSON
  • I'm using jQuery for as much heavy lifting as possible, but I haven't seen much JSON-specific support in jQuery
  • One example I've seen of getting JSON out of a file used eval, which I instinctively shy away from
  • I just haven't found any good reference that has convinced me that JSON is worth the learning curve

What do you guys have to say? Will there be a noticable performance difference between using XML and JSON? If I'm better off doing this with JSON than XML, is there some really good documentation on best practices, or maybe a nice jQuery plugin I'm missing? Maybe there are other data formats I haven't considered beyond XML or JSON (though I already know I don't want to use a relational database).

I'd like it to be simple, intuitive, and fast. I know that the XML format is the first two, I'm not sure about the third.

Also, there's no reason that I have to use Google Maps' geocoding service. Any recommendations for other services that might work better for looking up a large number of requests, but doing so infrequently? I'm starting to look into some of the options here but I'd love to get some input on particularly good/fast/easy-to-use services.

Edit: whatever service I use needs to support intersections as well as proper addresses.

A: 

If the files are small and local, there shouldn't be much difference between XML and JSON for storage, so you should go with what's easier for you.

json.org has pointers to open source JSON parsers and serializers in just about any programming language imaginable, if you decide to go that route.

If eval in JavaScript is what scares you, JavaScript now has evalJSON which ameliorates the code-exploit concerns.

lavinio
In XML form, the pre-cached data is about 2 megabytes. Not too bad.
Matt Ball
There's no reason to bother with evalJSON if the JSON file is something you generated and wrote to your own server. Nothing wrong with eval in that circumstance.
Andrew