Oops. Just saw the OP date. It's too late to edit my post but you've almost certainly solved it or given up by now. Oh well, maybe it'll help someone. My only other piece of advice is that writing a reliable, generic JSON parser (ironically worse than XML, IMO) from scratch is intermediate to advanced level, depending on the language (Perl = mid, C++ [esp. pre-11/14/17] = hard), so use a verified or at least road-tested package from someone else. I wrote a JSON parser in C++ for the Discogs API and it was hacky as ****. It was sort of halfway between a finite state machine and a spaghetti mess of static callback functions. It worked reliably but only by knowing the exact format and order of Discogs' web service responses. If they ever change it, it'll stop working. It was a hackjob for a highly-specific use case.