Bugfix - update type when updating value.

In my app a value changes from `"sample1"` to `false`.

It changes the type from `string` to `boolean`. 

This caused an error: 

Before: An error is thrown, because `escapeString` cannot escape a boolean (i.e. booleans don't have a `replace` function)
After: No error is thrown.