Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

      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
             . . .

Similar code can be used to validate if the structure of the document is correct.  So, before the For/Endfor:

     If_Ref Com(#JsonDoc.RootNode<'results'>) Is_Not(*NULL)
For Each(#Result) In(#JsonDoc.RootNode<'results'>)
Endfor
Endif

Next: Re-using the XPRIM_HttpRequest Object