PubSub Whiser Message Format Error?

I started to mess around with PubSub and I ran into an issue. I’m testing the whisper event and everything is going smoothly until I go to deserialize the data field. Everything deserializes fine up to the child data field inside of the parent data field. It appears that the data field of the message field is not formatted properly. At a glance, it looks like it is missing a closing bracket.

Here is is the full message filed attempting to be deserialized:

"{\"type\":\"whisper_received\",\"data\":\"{\\\"message_id\\\":\\\"dbe13db7-923d-4f31-adcb-06aa7b0ca446\\\",\\\"id\\\":511,\\\"thread_id\\\":\\\"45947671_51012150\\\",\\\"body\\\":\\\"test whisper\\\",\\\"sent_ts\\\":1490311704,\\\"from_id\\\":51012150,\\\"tags\\\":{\\\"login\\\":\\\"rokubotto\\\",\\\"display_name\\\":\\\"RokuBotto\\\",\\\"color\\\":\\\"#00FF7F\\\",\\\"user_type\\\":\\\"\\\",\\\"turbo\\\":false,\\\"emotes\\\":[],\\\"badges\\\":[]},\\\"recipient\\\":{\\\"id\\\":45947671,\\\"username\\\":\\\"sixdegreesofgaming\\\",\\\"display_name\\\":\\\"SixDegreesOfGaming\\\",\\\"color\\\":\\\"#FF0000\\\",\\\"user_type\\\":\\\"\\\",\\\"turbo\\\":true,\\\"badges\\\":[{\\\"id\\\":\\\"premium\\\",\\\"version\\\":\\\"1\\\"}],\\\"profile_image\\\":null},\\\"nonce\\\":\\\"wL78GRCydKkHkQwRplRmYgQvT4rVOH\\\"}\",\"data_object\":{\"message_id\":\"dbe13db7-923d-4f31-adcb-06aa7b0ca446\",\"id\":511,\"thread_id\":\"45947671_51012150\",\"body\":\"test whisper\",\"sent_ts\":1490311704,\"from_id\":51012150,\"tags\":{\"login\":\"rokubotto\",\"display_name\":\"RokuBotto\",\"color\":\"#00FF7F\",\"user_type\":\"\",\"turbo\":false,\"emotes\":[],\"badges\":[]},\"recipient\":{\"id\":45947671,\"username\":\"sixdegreesofgaming\",\"display_name\":\"SixDegreesOfGaming\",\"color\":\"#FF0000\",\"user_type\":\"\",\"turbo\":true,\"badges\":[{\"id\":\"premium\",\"version\":\"1\"}],\"profile_image\":null},\"nonce\":\"wL78GRCydKkHkQwRplRmYgQvT4rVOH\"}}"

And here’s what it looks like when the watch window in VS tries to parse through the string:

Parses just fine.

Well, beats me what I’m doing wrong. I also tried several online JSON formatters and even they couldn’t deserialize it properly.

Note the $.data is a JSON-formatted string inside the parent JSON. You need to deserialize it separately after deserializing the main JSON.

1 Like

Well, that would explain it. I was going purely off of the example response in the docs and the child data within the message was formatted differently. Thanks for the help.

Interesting discrepancy. cc @DallasNChains

Oh. Dang. I thought I updated all those when we consolidated to a single page. I’ll get it fixed soon!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.