Post data as JSON

I needed to post JSON data to a URL. I did not find a way to do it with the original code.
I might be wrong. Let me know ;)