I want PHP to send a 10000-character JSON array to a Java program and get a JSON array in return.
There is the exec() method for calling subprocesses, but I dont know how to reliably pass a long string. I see two methods:
Method 1: Pass the entire string in the commandline. I am worried how to escape a JSON string for the commandline and if it is too much for a Linux commandline to handle. ROFLMAO anyone?
Method 2: Make the java program wait for a \n-terminated string from STDIN. PHP can send the string to the STDIN of that Java program.
What is a good method to pass a long string to a Java subprocess?
Hmm wouldn’t a temporary file as input be the cleanest solution here? Sorry if this won’t suit but it probably would make life easier for debugging too