def from_json ( value , * * kwargs ) : if isinstance ( value , string_types ) : value = value . upper ( ) if value in ( 'TRUE' , 'Y' , 'YES' , 'ON' ) : return True if value in ( 'FALSE' , 'N' , 'NO' , 'OFF' ) : return False if isinstance ( value , int ) : return value raise ValueError ( 'Could not load boolean from JSON: {}' . format ( value ) )
python json decode boolean
Coerces JSON string to boolean
def from_json(value, **kwargs):
        """Coerces JSON string to boolean"""
        if isinstance(value, string_types):
            value = value.upper()
            if value in ('TRUE', 'Y', 'YES', 'ON'):
                return True
            if value in ('FALSE', 'N', 'NO', 'OFF'):
                return False
        if isinstance(value, int):
            return value
        raise ValueError('Could not load boolean from JSON: {}'.format(value))