encode string before json decode