question

Geo avatar image
Geo asked

Unreal Engine Cloud Script Result Json String Parsing

How are able to get json array inside ue4 bp , Getting function get field as string returns entire json as string to me but i kinda need to parse json array which is ResultData .

apisunreal
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Citrus Yan avatar image Citrus Yan commented ·

May I know how did you set up the BP? Maybe some screenshots of that?

0 Likes 0 ·
Citrus Yan avatar image
Citrus Yan answered

I believe you should use the "Get Object Array Field" node to get the "ResultData" as a array:


bp.png (63.5 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Geo avatar image
Geo answered

I just already put the ss while creating the topic but yeah something went wrong i guess.



This is my title Data

{
"ResultData": [
{
"Server_ID": "0",
"Server_Name": "Asgardia",
"Server_IP": "127.0.0.1",
"Server_Port": "7777"
},
{
"Server_ID": "1",
"Server_Name": "Leonard",
"Server_IP": "127.0.0.1",
"Server_Port": "7777"
}
]
}

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Geo avatar image Geo commented ·
CloudScript Result:

{ "FunctionResult": { "obj": { "ServerInformation": "{\"ResultData\":[{\"Server_ID\":\"0\",\"Server_Name\":\"Asgardia\",\"Server_IP\":\"127.0.0.1\",\"Server_Port\":\"7777\"},{\"Server_ID\":\"1\",\"Server_Name\":\"Leonard\",\"Server_IP\":\"127.0.0.1\",\"Server_Port\":\"7777\"}]}" } }, "Logs": [], "ExecutionTimeSeconds": 0.0303603, "MemoryConsumedBytes": 12248, "APIRequestsIssued": 1, "HttpRequestsIssued": 0, "Error": null }
0 Likes 0 ·
Geo avatar image Geo commented ·

CloudScript Revision Js Code


handlers.TestRequest = function (args,context) {

var data = args.titleName;

var value = server.GetTitleData({

Keys : [data]

});

// log.info(value);
// log.info(value.Data[data]);


//return {"Value" : value.Data[data]};
// return JSON.parse(JSON.stringify(value.Data[data]));
var obj = value.Data;
return {obj};
};

0 Likes 0 ·
Geo avatar image
Geo answered

handlers.GetServerInformationTitleData = function (args,context) {

var data = args.titleName;

var value = server.GetTitleData({

Keys : [data]

});



return JSON.parse(value.Data[data]); /// this does the fix cuz return object was not coming as an array it was like string .

};

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.