Trying to create JSON type header for OkHttp3
val JSONtype = MediaType.parse("application/json; charset=utf-8")
But the following error is coming :
Using 'parse(String):MediaType?' is an error. moved to extension function
Shown solution/suggestion:
val JSONType = "application/json; charset=utf-8".toMediaTypeOrNull()
Do the serve the same action or requirement?
Yes.
You can check out migration guide:
https://square.github.io/okhttp/upgrading_to_okhttp_4/#extension-functions
Instead of
MediaType.parse(yourString)
use
yourString?.toMediaTypeOrNull()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With