Made JSON parsing more generic.