Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"As string" fails to serialize the message JSON object #64

Closed
ashah28 opened this issue Nov 2, 2017 · 3 comments
Closed

"As string" fails to serialize the message JSON object #64

ashah28 opened this issue Nov 2, 2017 · 3 comments

Comments

@ashah28
Copy link

ashah28 commented Nov 2, 2017

Hello developers,

It seems the "As string" blueprint node is failing to convert the JSON message to string.

For all the combinations I have tried, I get the following in the output log:
LogJson: Error: Json Value of type 'Object' used as a 'String'.

Attaching the combinations that I tried and failed:
2017-11-02 13_44_05-firstpersoncharacter_
2017-11-02 13_45_36-firstpersoncharacter_

My approach was almost the same as the third image in the project's home page(https://github.com/getnamo/socketio-client-ue4):
687474703a2f2f692e696d6775722e636f6d2f76566c4e426c782e706e67

Apparently, the data format from the socket seems correct as the following blueprint works fine:
2017-11-02 13_49_50-firstpersoncharacter_

Response that I am sending from the server:

emit('connection response', {'data': 'Connected'}) where,
'connection response' is the event and
'{'data': 'Connected'}' is the JSON message

UE version: 4.17.1

Thank you.

@ashah28 ashah28 changed the title "As string" fails to serialize the message JSON "As string" fails to serialize the message JSON object Nov 2, 2017
@getnamo
Copy link
Owner

getnamo commented Nov 3, 2017

You're getting this error because your JSON type is an object not a string. The function As String tries to interpret a json value to a string, since it is not a string, but an object, it is throwing that warning.

What you want to do however is to convert an SIOJson Value or Object to its JSON string representation. To do this you need to use the function EncodeJsonString instead.

I believe the documentation is a bit hazy on this and it may be good to have an implicit conversion from the As String function. I guess that depends on whether UE4 developers prefer explicit typing or more javascript like duck typing behavior.

@getnamo
Copy link
Owner

getnamo commented Nov 3, 2017

Decided to add auto-conversion by default here: 2b118c4

Will sweep up other issues before making a 4.18 release however.

@ashah28
Copy link
Author

ashah28 commented Nov 3, 2017

Sure, Thanks for the enhancement.

@ashah28 ashah28 closed this as completed Nov 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants