Share your advanced knowledge/code with the community.
-
falsam
- Posts: 280
- Joined: Mon May 05, 2014 9:49 pm
- Location: France
-
Contact:
Post
by falsam »
Script Php
Code: Select all
<?php
$array = array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
echo json_encode($array);
?>
Code SpiderBasic
Code: Select all
Enumeration
#Json
EndEnumeration
Procedure HttpGetEvent(Success, Result$)
Protected i
If Success
Debug Result$
If ParseJSON(#Json, Result$)
ObjectValue = JSONValue(#Json)
If ExamineJSONMembers(ObjectValue)
While NextJSONMember(ObjectValue)
Debug JSONMemberKey(ObjectValue) + " = " + GetJSONInteger(JSONMemberValue(ObjectValue))
Wend
EndIf
EndIf
Else
Debug "HTTPRequest(): Error"
EndIf
EndProcedure
HTTPRequest(#PB_HTTP_Get, "receivedata3.php", "", @HttpGetEvent())
Test:
http://s242132022.onlinehome.fr/sb-demophp3/index.html
➽ Windows 11 - JDK 1.8 - SB 2.40 - Android 13
➽ http://falsam.com
Sorry for my poor english
-
freak
- Posts: 7
- Joined: Mon Feb 24, 2014 10:26 pm
- Location: Germany
Post
by freak »
You can also get the data directly into a PB Map like this:
Code: Select all
Enumeration
#Json
EndEnumeration
Procedure HttpGetEvent(Success, Result$)
Protected i
If Success
Debug Result$
If ParseJSON(#Json, Result$)
; transfer the php array to a map
NewMap Values.l()
ExtractJSONMap(JSONValue(#Json), Values())
; display the result
ForEach Values()
Debug MapKey(Values()) + " = " + Values()
Next Values()
EndIf
Else
Debug "HTTPRequest(): Error"
EndIf
EndProcedure
HTTPRequest(#PB_HTTP_Get, "receivedata3.php", "", @HttpGetEvent())
-
falsam
- Posts: 280
- Joined: Mon May 05, 2014 9:49 pm
- Location: France
-
Contact:
Post
by falsam »
Thank you freak. This solution is more interesting than mine.
➽ Windows 11 - JDK 1.8 - SB 2.40 - Android 13
➽ http://falsam.com
Sorry for my poor english