How to send and get JSON? Java | Python
Question:
I’ve just start learning Spring Boot. How can I do this:
I have: spring boot application, python file.
- Python file must send JSON to server (spring app)
- Spring app must get it and show in console
Maybe I have to use module responce in python?
Answers:
You can make both machines communicate using http protocol.
To do so, you will have to create a server on the other computer (using Flask, Django, FastApi if you wish to write in Python). You just have to create a GET endpoint to serve the client (your machine running the react app). The client will simply call the server on the right route when needed.
All of this can work on local network.
I don’t know Spring Boot that well, but I guess you should get a dependency on some JSON library like Gson, Yasson or Jackson. Perhaps do a few Google searches on them in combination with Spring Boot? It could be that I am misunderstanding your question. Are you trying to receive JSON with SB? What is the role of Python? Both SB and Pyton are ‘server side’. You can send JSON from your React.js page to either your Python program or your SB program and get a response in JSON (or something different) back from the server (SB/Python) after you have processed the request.
I’ve just start learning Spring Boot. How can I do this:
I have: spring boot application, python file.
- Python file must send JSON to server (spring app)
- Spring app must get it and show in console
Maybe I have to use module responce in python?
You can make both machines communicate using http protocol.
To do so, you will have to create a server on the other computer (using Flask, Django, FastApi if you wish to write in Python). You just have to create a GET endpoint to serve the client (your machine running the react app). The client will simply call the server on the right route when needed.
All of this can work on local network.
I don’t know Spring Boot that well, but I guess you should get a dependency on some JSON library like Gson, Yasson or Jackson. Perhaps do a few Google searches on them in combination with Spring Boot? It could be that I am misunderstanding your question. Are you trying to receive JSON with SB? What is the role of Python? Both SB and Pyton are ‘server side’. You can send JSON from your React.js page to either your Python program or your SB program and get a response in JSON (or something different) back from the server (SB/Python) after you have processed the request.