Sign In Register

How can we help you today?

Start a new topic
Solved

JSON true value parsed into 0 in cloud code

Hi


If I assign JSON value true to event attribute, in cloud code I get 0 of that value.

{"valueKey":true}


It can be duplicated by test harness.

Jo


Hello Jo Huang,


I can see that your event accepts bool parameter as a number, that's why passing in a boolean value throws a REQUIRED error, there are two solutions here:


1. Pass in 1 for true, and 0 for false, Cloud Code is based on JavaScript and is able to parse truthy/falsy values both false == 0 and true == 1, are true.

2. Pass in a JSON value into your event: "booleans" : {"bool1" : true, "bool2" : false}


Let me know if this helps,


Mantas

Hi, Mantas


I set the default value to 0, and seems that server doesn't treat "true" as valid value, so it passed 0 to cloud code.

If I didn't set the default value, the request will be error with "somekey REQUIRED" message.


This would affect the iOS SDK if I pass @(YES) to event request.


The following is the screenshot of simple echo event.


Hello Jo Huang,


Could you please raise a support ticket with the replication steps, as I'm unable to replicate this.


Regards,


Mantas

Login to post a comment