Save boolean data types in serialized array
This would be much easier to do on the client side. Assuming val is your boolean value, you can just add a single line to handle this:

val = +val;


That will coerce your boolean to an integer (1 or 0). No need to check all of the json data on the server side.