SocketIOClient-Unreal icon indicating copy to clipboard operation
SocketIOClient-Unreal copied to clipboard

Question about how to parse JSON

Open Osony opened this issue 4 years ago • 8 comments

Hello, i am trying parse simple JSON string for test, i place node "Make literal string" with value: {"test":"valueTest"} This string will come from outsource, unrelated with this plugin Then i try parse it many ways, but everytime get empty First it decoding it and print, second it encoding to string and print, third it placing object to structure, break struct and print string - any of this way don't work, also if i try write [] (square parentheses) and parse it like array! image image After trying to print everything in log, i get that after converting from value to object, json string is become empty. But if i trying to create json from this plugin - it works! image I print initial (literal) string and this thing above, they are same! I not undestand, same strings but 1 don't parsing and 2 parsing perfectly! Outsource is not NodeJS server or something, is just string from UDP

Osony avatar Dec 25 '21 03:12 Osony

https://github.com/getnamo/socketio-client-ue4/issues/296

BavGames avatar Dec 25 '21 21:12 BavGames

#296

There the problem is that the array was received. But in my case i received not array! As i already said, i try to get my string in array like: [{"test":"valueTest"}] And get elements image But this won't work. Value is get empty after converting to Object Print after "To JsonValue (String)" - exist, print after "To Object (JsonValue)" - empty image

Osony avatar Dec 26 '21 04:12 Osony

#296

Sorun şu ki, dizi alındı. Ama benim durumumda dizi almadım! Daha önce de söylediğim gibi, dizimi şu şekilde diziye almaya çalışıyorum: [{"test":"valueTest"}] Ve öğeleri alıyorum Ama bu işe yaramayacak. Değer "To JsonValue (String)"den sonra Object Print'e dönüştürüldükten sonra boş oluyor - var, "To Object (JsonValue)" sonrasında yazdır - boş resim resim

Json value(string) AS Array > For each loop > as object > get string field {fieldname:test} > print string

BavGames avatar Dec 26 '21 04:12 BavGames

download Varest plugin for more features use it with the plugin it works very well

BavGames avatar Dec 26 '21 04:12 BavGames

download Varest plugin for more features use it with the plugin it works very well

I don't use Rest server UE4.26 - latest for him socketio is 1.6.0, but in plugin UDP that i use from same developer, where is socketio included - 1.5.5, i don't see in 1.6.0 changelog some changes for my problem And i already done that you wrote image

Osony avatar Dec 26 '21 06:12 Osony

To parse a raw json string from e.g. some other source use ValueFromJsonString(UObject* WorldContextObject, const FString& StringValue); (https://github.com/getnamo/socketio-client-ue4/blob/9765f50ffc5b0a4cde6486c8538cc72befe5c425/Source/SIOJson/Public/SIOJsonValue.h#L110)

Using to json value will wrap the string value as an json value type, not decode the string as you're expecting.

For the other way (siojsonvalue to string) you want to use Encode json node (https://github.com/getnamo/socketio-client-ue4/blob/9765f50ffc5b0a4cde6486c8538cc72befe5c425/Source/SIOJson/Public/SIOJsonValue.h#L160)

getnamo avatar Dec 29 '21 08:12 getnamo

I get this plugin because i not understand programming and hope to do my work in blueprints, but if i need to work with code, i have to switch to another plugin(

Osony avatar Dec 30 '21 06:12 Osony

These are blueprint callable functions, same name as c++, drag off node and type the name out

getnamo avatar Dec 30 '21 07:12 getnamo