I'm trying to send JSON from a Python client to a Java server
The JSON data type is bytes (in Python) and when I deserialize it (in Python) and print it, it looks perfect. The server works fine when a Java client connects and when I deserialize the JSON and print it in Java it looks exactly the same as in Python and the actual JSON files. The JSON all looks good, but the data isn't accepted by the Java server.
data = open(file_path, 'r').read() # reading JSON object as string
serialized_data = pickle.dumps(data)
s.send(serialized_data)
When I send a JSON file the Java server acknowledges the connection but the JSON data for whatever reason isn't accepted.
Java Client
String sentence = new String(readFile());
if(!sentence.equals("fileNotFound")) {
ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
oos.writeObject(sentence);
}
Java Server
ObjectInputStream inFromClient = new ObjectInputStream(socket.getInputStream());
String clientString = null;
try {
clientString = (String) inFromClient.readObject();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
inFromClient.close();