Page 1 of 1

Receive Php Array() : HTTPRequest() and ParseJSON()

Posted: Thu Sep 04, 2014 8:08 pm
by falsam
:arrow: receivedata.php

Code: Select all

<?php
	$array = array("foo", "bar", "hello", "world");
	echo json_encode($array);
?>
:arrow: Code Spiderbasic

Code: Select all

Enumeration
  #Json
EndEnumeration

Procedure HttpGetEvent(Success, Result$)
  Protected i
  
  If Success
    
    Debug Result$
    
    ParseJSON(#Json, Result$)
    
    For i = 0 To JSONArraySize(JSONValue(#Json)) - 1
      Debug GetJSONString(GetJSONElement(JSONValue(#Json), i))
    Next i
   
  Else
    Debug "HTTPRequest(): Error"
  EndIf
EndProcedure

HTTPRequest(#PB_HTTP_Get, "receivedata.php", "", @HttpGetEvent())

Works fine :)