If you expect to see a JSON response from your HTTP request, it's recommended that you always verify that the HTTP response is indeed a well-formed JSON.
If you are using XPRIM_RandomAccessJsonReader (or XPRIM_JsonReader), you can check the error information returned when you set the source response (using SetSourceHttpResponse method).
The following example builds upon the example from the previous section. Notice that we know declare a component of type XPRIM_ErrorInfo, and pass it when we call the SetSourceHttpResponse method. We then check the OK property of the error info object to check if the JSON reader successfully reads the HTTP response body (which indicates that response is a well-formed JSON string)
Define_Com Class(#XPRIM_HttpRequest) Name(#Req)
Define_Com Class(#XPRIM_RandomAccessJsonReader) Name(#Reader)
Define_Com Class(#XPRIM_ErrorInfo) Name(#ErrorInfo)
...
#Req.DoGet Url('https://maps.googleapis.com/maps/api/geocode/json?...')
* Check if request is successful
If (#Req.Response.IsSuccessHttpStatusCode)
* Set the JSON reader source fot response from the HTTP request
#Reader.SetSourceHttpResponse HttpResponse(#Req.Response) ErrorInfo(#ErrorInfo)
If (#ErrorInfo.OK)
* Read JSON values
. . .