Fixed invalid conversion if Content-Type header includes optional parameters like charset, and fixed invalid conversion of json

Fixed conversion of input data in case Content-Type header includes optional parameters like `charset` (e.g. `text/html; charset=UTF-8`. Also fixed invalid conversion of json.