I'm trying to send a JSON string using CURL command and Runtime.getRuntime.exec() function.
My JSON string is something like:
String jsonString = "{\"object\":[\"something\",\"another something\"]}"
I'm trying to send this string using the following function:
Process p;
p = Runtime.getRuntime().exec(new String[] {"curl","someURL","-H","Content-Type:application/json","-d",jsonString,"-u","something:something"}
Once I execute the following lines and parse the output, I get an error saying that the JSON document is not valid. When I try the same command using command line, it works just fine. I think the problem is with the JSON string as the escape characters are also being send as a part of the JOSN data and hence the invalid JSON data output.
Is there anything that I have done wrong or is there any other way that I have to execute the command.