IdHttp : how to deal with json request and response
<p>I have encountered a few sites that uses <code>JSON</code> for request and response<br>
I come across two types :<br>
<strong>1-</strong> <code>application/x-www-form-urlencoded</code> as request and return a response <code>application/json</code> content type<br>
<strong>2-</strong> <code>application/json</code> content type for both request and response<br>
in <code>type 1</code> i tried changing the the response content type using<br>
<code>mIdHttp.Response.ContentType := 'application/json';</code><br>
but using http analyzer i can see that it doesn't change and its still <code>text/html</code><br>
now i do not know if the problem is with the fact that i can't change content type or not but i do not know how to deal with <code>json</code> !<br>
a few question regarding <code>json</code> :<br>
<strong>1-</strong> do i have to encode json data when posting ? how ?<br>
<strong>2-</strong> how can i parse the json response code ? how to get it ? does it need some kind of encode or special convertion ?<br>
<strong>3-</strong> what kind of idhttp setting for json changes with each site and needs configuring ?  </p>

<p>I understand my questions sound a bit general, but all the other questions are very specific and don't explain the basics when dealing with <code>'application/json'</code> content type.  </p>

<p><strong>Edit 1 :</strong><br>
thanks to <strong>Remy Lebeau</strong>  answer i was able to successfully work with <code>type 1</code><br>
but i still have trouble sending <code>JSON</code> request, can someone please share an working example, this is one of the sites posting information please use this for your example :<br>
<a href="https://i.stack.imgur.com/Ib4Rf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ib4Rf.png" alt="enter image description here"></a>  </p>

<p><strong>One important note :</strong>  this particular site's post and request content are exactly like each other ! and it baffles me because at the site, i specify an <code>start date</code> and an <code>end date</code> then click on a <code>folder like icon</code> and this <code>post</code> is sent (the one you can see above), and the <code>result</code> should be <code>links</code> (and it is) <strong>but</strong> instead of appearing only in <code>request content</code> they also appear in <code>post</code> !  (also i'm trying to get the links but at the <code>post</code> the links, the thing i want, are also being sent, how can i post something i don't have !!?) </p>

<p><strong>just for more clarity</strong> here is the place i fill the date and the icon i mentioned :<br>
<a href="https://i.stack.imgur.com/0LDP2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0LDP2.png" alt="enter image description here"></a></p>