How to set content type = "application / json" in mule.?

I have an HTML file that consists of a form and accepts certain parameters from the user, and when the URL hits, the mule service (written in java) is called and returns a json string. Now, how can I set the content type = "application / json" in mule or java so that the browser knows that it is receiving JSON.?

My Mule configuration file:

           

      

    <not-filter>
                <wildcard-filter pattern="/favicon.ico"/>
            </not-filter>

        </http:inbound-endpoint>

<component class="defaults.basicapp.jcars"/>

</flow>

And my java class (Jcars):

public String onEvent (Object obj) {

String json = "{{" id ": 0," model ":" suzuki "," make ":" 2002 "," ps ": true," price ": 101.2," bhp ": 12.6} {" ID ": 0," ":" "," ":" 2003 "," ": ," ": 101,2," . ": 12,6}, {" ID ": 0," ":" "" ":" 2004 "," ": ," ": 101,2," ": 12,6}, {" ID ": 0," ":" "," ":" 2005 "," ": ," ": 101,2," . ": 12,6}, {" ID ": 0," ":" "," ":" 2006 "," ": ," ": 101,2," .. ": 12,6}}";

return json; }

. , - application/json. .

+5
1

, :

<response>
  <message-properties-transformer>
    <add-message-property key="Content-Type" value="application/json" />
  </message-properties-transformer>
</response>
+8

All Articles