Home > Enterprise >  How to send and get JSON? Java | Python
How to send and get JSON? Java | Python

Time:08-08

I've just start learning Spring Boot. There is my question:

I have a spring boot application (React.js SB) and a python file on another computer. How can I send JSON file or JSON data to server from python file, and get it on Spring Boot server, show in client (React.js) it. Thank you!

P.S I know it's impossible to do it while SB application on localhost, I need java and python script, before I release app.

CodePudding user response:

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.

CodePudding user response:

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.

  • Related