Boolean value in dict

Masayuki Akamatsu's icon

I can turn a Philips Hue off with JavaScript.

function bang()
{
    ajaxreq = new XMLHttpRequest();
    ajaxreq.open("PUT","http://10.0.1.2/api/masayukiakamatsu/lights/1/state");
    ajaxreq.send('{"on":false}');
}

But I can't describe it in a dict object (for maxurl).

{
    "http_method" : "PUT",
    "url" : "http://10.0.1.2/api/masayukiakamatsu/lights/1/state",
    "post_data" :     {
        "on" : false
    }
}

false becomes null after saved. "false" and 0 doesn't work well.

So my question is how to describe a boolean value (true and false) in a dict object.

Thank you for your advice.

MaxHueTest.maxpat
Max Patch
MaxHueTest.js
js
Vato Gonzalez's icon

I was struggling with this as well, after a long search I've found the answer right here on the forum. The HUE lights respond now!

https://cycling74.com/forums/change-dot-in-float-to-comma

Sergio Lecuona's icon

I'm having the same problem with booleans as "true"/"false" inside [dict].
In my case is for sending a http request with [maxurl] stored in a [dict]. Looks like either is parsed as int or as string if I apply quotes ("true").

Anyone any workaround? Am I missing a [dict] attribute or setting?