I think I may have uncovered a bug in event.RenderData. I have a model which has a getter called getPayload(). For the most part this returns text - i.e chat messages that someone has sent to another person. The problem occurs when the message someone typed is "Yes" or "No".
The problem that is occurring is event.renderData is then converting "Yes" into a boolean (true), which is then being converted to 1 or 0 in the final app. There might be a way for me to get around this by modifying the getter in the model, but wondering if anyone else can confirm this behavior? Note: I did a quick dump to logbox prior to running event.RenderData and the value dumped out as "Yes".
The contents of Payload in the DB could be any string... i.e "foo", "yes", "no", "this is my message"
it's only when the value in the DB is "yes" or "no" that it is being converted to true or false. it's being converted to JSON in my postHandler. the value returned from getPayload() returns a string with a value of "yes" (the value that was in the db) and event.RenderData as JSON is what is is converting it to a boolean as opposed to treating the value as a string
I understand. I found a way…errr…hack to get around it by evaluating the value of getPayload(). If it returns “yes” or “no” I add a space "yes " / "no " and then it is not treated as a boolean.
This is not the most elegant way to get around this issue, but it works for now. Any other suggestions are appreciated, but at least I have it working now.
Since these are chat messages I would apply your hack to each message instead of just Y/N. At least then it wont be a hack and will be common among all messages
Good point, however the payload field holds more than just text. The model for the data is an Event object. Event Objects have event types, and a type could be text message or a type could be photo. If it were photo the Payload field would contain the Base64 value of the photo. So essentially I need to narrow the hack down to just Y/N otherwise I’m adding extra data to payloads.