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

Share your advanced knowledge/code with the community.
falsam
Posts: 280
Joined: Mon May 05, 2014 9:49 pm
Location: France
Contact:

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

Post 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 :)

➽ Windows 11 - JDK 1.8 - SB 2.40 - Android 13
http://falsam.com

Sorry for my poor english