implements string encoding.
prepare json write