2 примера , локальная работа и методом POST/GET
Add(MainForm,11264494,427,336)
{
Width=543
Height=557
BorderStyle=3
}
Add(VBJScript,3294728,476,154)
{
WorkPoints=#6:doWork|
EventPoints=#22:onEvent=Ответ по ключу|
DataPoints=#20:jsonObject=Тело Json|14:path=Ключ Json|
Language=1
Script=#16:function Main() |1:{|34: var jsonText = sys.jsonObject;|24: var path = sys.path;|19: var jsonObject;|9: try {|42: jsonObject = JSON.parse(jsonText);|17: } catch (e) {|49: jsonObject = eval('(' + jsonText + ')'); |9: } |31: var keys = path.split('.');|4: |26: var out1 = jsonObject;|43: for (var i = 0; i ‹ keys.length; i++) {|51: if (out1 && out1.hasOwnProperty(keys[i])) {|33: out1 = out1[keys[i]];|16: } else {|24: out1 = null;|18: break;|9: }|5: }|0:|22: sys.onEvent(out1);|1:}|0:|29:function doWork(Data, Index) |1:{|11: Main();|1:}|0:|
UseName=0
link(onEvent,5505261:doMessage,[])
link(jsonObject,494812:Text,[])
link(path,9274430:String,[(489,146)(538,146)])
}
Add(Message,5505261,602,154)
{
}
Add(StrList,494812,476,98)
{
Strings=#1:{|21: "personalInfo": {|20: "contact": {|22: "phone": {|41: "mobile": "123-456-7890",|38: "home": "098-765-4321"|14: },|42: "email": "example@example.com"|10: },|27: "name": "John Doe",|17: "age": 30|6: },|16: "friends": [|9: {|28: "name": "Alice",|24: "contact": {|45: "email": "alice@example.com",|26: "phone": {|44: "mobile": "555-123-4567"|17: }|13: }|10: },|9: {|26: "name": "Bob",|24: "contact": {|43: "email": "bob@example.com",|26: "phone": {|44: "mobile": "555-987-6543"|17: }|13: }|9: }|5: ]|1:}|
}
Add(ComboBox,9274430,525,98)
{
Left=10
Top=10
Width=210
Height=21
Strings=#33:personalInfo.contact.phone.mobile|17:personalInfo.name|16:personalInfo.age|31:personalInfo.contact.phone.home|
Text="personalInfo.contact.phone.mobile"
link(onClick,3294728:doWork,[(582,111)(582,78)(464,78)(464,160)])
}
Add(VBJScript,12261476,476,378)
{
WorkPoints=#6:doWork|
EventPoints=#31:onGET=Результат метода GET/POST|21:onJson=Ответ по ключу|25:onError=Ошибка соединения|
DataPoints=#19:URL=Ссылка на адрес|21:Path=Ключ вывода JSON|30:Type=Протокол Запроса GET/POST|
Language=1
Script=#16:function Main() |1:{|32:// Создаем объект XMLHttpRequest|46:var xhr = new ActiveXObject("MSXML2.XMLHTTP");|18:// URL для запроса|57:var url = "http://users.bugred.ru/tasks/rest/doregister";|43:// Открываем GET-запрос (синхронный запрос)|31:xhr.open(sys.Type, url, false);|20:// Отправляем запрос|11:xhr.send();|27: // Проверяем статус ответа|26: if (xhr.status === 200) {|49: // Если запрос успешен, выводим результат|40: var response = xhr.responseText;|28: sys.onGET(response);|10: } else {|49: // Если произошла ошибка, выводим сообщение|69: sys.onError("Error: " + xhr.status + " - " + xhr.statusText);|2: }|0:|7:// JSON|28: var jsonText = response;|24: var path = sys.Path;|19: var jsonObject;|9: try {|42: jsonObject = JSON.parse(jsonText);|17: } catch (e) {|49: jsonObject = eval('(' + jsonText + ')'); |9: } |31: var keys = path.split('.');|4: |26: var out1 = jsonObject;|43: for (var i = 0; i ‹ keys.length; i++) {|51: if (out1 && out1.hasOwnProperty(keys[i])) {|33: out1 = out1[keys[i]];|16: } else {|24: out1 = null;|18: break;|9: }|5: }|0:|21: sys.onJson(out1);|0:|0:|2: |1:}|0:|29:function doWork(Data, Index) |1:{|11: Main();|1:}|
UseName=0
link(URL,9448768:Value,[])
link(path,5413272:Value,[])
link(onGET,5633026:doWork2,[])
link(onJson,8850742:doMessage,[])
link(onError,5633026:doWork3,[(627,398)])
link(Type,15732142:String,[(496,345)(566,345)])
}
Add(Button,9949780,427,378)
{
Left=10
Top=45
Width=90
Caption="GET/POST"
link(onClick,12261476:doWork,[])
}
Add(Memory,9448768,476,245)
{
Default=String(http://users.bugred.ru/tasks/rest/doregister)
}
Add(Memory,5413272,483,294)
{
Default=String(message)
}
Add(Message,8850742,574,385)
{
}
Add(ComboBox,15732142,553,294)
{
Left=120
Top=45
Width=100
Height=21
Strings=#3:GET|4:POST|
Text="GET"
}
Add(Memo,3977903,714,378)
{
Top=103
Width=537
Height=425
Align=4
ScrollBars=3
}
Add(Hub,182158,658,378)
{
link(onEvent1,3977903:doClear,[(682,384)(682,391)])
link(onEvent2,3977903:doAdd,[(682,391)(682,384)])
}
Add(HubEx,5633026,623,378)
{
link(onEvent,182158:doEvent1,[])
}
Add(InfoTip,16636110,420,49)
{
Info=#8:Локально|
Width=288
Height=186
}
Add(InfoTip,5862749,420,238)
{
Info=#16:методом POST/GET|
Width=372
Height=207
}
Редактировалось 1 раз(а), последний 2024-08-22 07:34:11