in reply to Parse JSON response

The posted code is generally correct. In order to know details, it is necessary to know more about your source. For example, if the host does not specify a content encoding, $body->decoded_content will fail. If the source is strict JSON, you should not allow non-references. If this is done in an automated fashion, you should add a time out and error handling to your ua. This should all be straight-forward once you start developing in earnest.