make /package/foo?json return JSON template context as a JSON object

also... there is an error in the existing logic

`Object.keys(request.query).indexOf('json') > -1` will always be true since even `indexOf` will return -1 when it doesn't find the key.