Updated for new encoding of JSON packets (sigh!)