You need to sign in to do that
Don't have an account?

Sending JSON object to servlet
Hi,
I have JSON object created using JSONGenerator class. I want to pass this JSON object to my servlet in java.
I want to send JSON object something like this http://www.xyz.com/basics/test.php(any extension here)?param=JSONObject.
where JSONObject is json object. and after that I want to write JSON parser inside my servlet (in java)
Can anyone help me, how to send JSON object to/from Salesforce and send/recievc JSON object in servlet.
Regards,
Abhishek
I have JSON object created using JSONGenerator class. I want to pass this JSON object to my servlet in java.
I want to send JSON object something like this http://www.xyz.com/basics/test.php(any extension here)?param=JSONObject.
where JSONObject is json object. and after that I want to write JSON parser inside my servlet (in java)
Can anyone help me, how to send JSON object to/from Salesforce and send/recievc JSON object in servlet.
Regards,
Abhishek
I think you need to visit below links which help you..
http://www.shivasoft.in/blog/salesforce/json-output-in-visualforce/
https://developer.salesforce.com/page/Getting_Started_with_Apex_JSON
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_json_jsongenerator.htm (https://developer.salesforce.com/page/Getting_Started_with_Apex_JSON)
IF it helps you than please mark it as a solution and ENJOY APEX (https://developer.salesforce.com/page/Getting_Started_with_Apex_JSON)
e.g.
So how I can achive this ?
How to define header of http so that it will know that it contains JSON object.
Thanks,
Abhishek
request.setHeader('Content-type','application/json');
request.setbody(JSONObject);
IF you want to send your json in parameter then may be URL lenght exceed. So you can set in your data in body.
But how I can retrive this JSON object in my java servlet code ?
Can you write simple example ?
because request.body does not work.
Also How I can send request using json as a parameter in the url?
Thanks,
Abhishek