ich finde die Idee mit dem Json De-/-Encoder unter Purebasic recht gut, habe allerdings hierbei mit dem Kontakt zu einem DB-Server Probleme :
Wenn ich folgende Struktur definiere :
Code: Alles auswählen
Define myJSON.jsonObj
myJson\o("command")\s = "CONNECT"
myJson\o("username")\s = sha1Username
myJson\o("password")\s = sha1Password
myJson\o("randpool")\i = randpool
JSON_Debug(@myJSON, "")
strResult.s = JSON_encode(@myJSON)
Debug "Testjson " + strResult
; creates a new file in tempdir and opens it with standard-program for *.txt files!
Define file.s = GetTemporaryDirectory() + "json.txt"
If CreateFile(0, file)
WriteString(0, strResult)
CloseFile(0)
RunProgram(file)
EndIf
Code: Alles auswählen
(object) : {
randpool(int) : 1234
password (string) : 18546076cbd1196640cfd2ca899bc5b8cfe04bb6
username (string) : e0489cd5c151d95f52ce708a6158bb8c3d05b6fc
command (string) : CONNECT
}
Code: Alles auswählen
{
"randpool" : 1234,
"password" : "18546076cbd1196640cfd2ca899bc5b8cfe04bb6",
"username" : "e0489cd5c151d95f52ce708a6158bb8c3d05b6fc",
"command" : "CONNECT"
}
Die Ausgabe müsste so aussehen :
Code: Alles auswählen
{ "command" : "CONNECT", "username" : "e0489cd5c151d95f52ce708a6158bb8c3d05b6fc", "password" : "18546076cbd1196640cfd2ca899bc5b8cfe04bb6", "randpool" : 1234 }
Michael
__________________________________________________
Code-Tags hinzugefügt
21.04.2013
RSBasic