in reply to Extracting data using JSON

Maybe you want to collaborate with Priti24 who seems to be working on the same problem?

As for "generalizing", I recommend you learn Perl, and look at concepts like "loops". For example, see perlsyn.