Update JSONWriter.php

Checking for is_string before trying to cast as string.