Recently I am writing a project that separates the front and back ends. The back end returns json data. Spring mvc provides the function of automatically returning an object to json. However, some data is completely useless to the front end, and it is impossible to re-assemble json by myself. How did everyone solve it
So why do major manufacturers define front-end not just on the browser side.
The reasonable way is to add a layer of data wrapping on the front end, such as using node.js to convert the secondary interface.
1. Determine the JSON format of the root server in advance before developing and connecting it
2. Use nodejs to add an intermediate layer to process the data. For example, in some cases, a signature is required and the transfer interface is also required
In principle, it is best not to support the back-end transmitting too much data to the front-end. If the front-end does not need the data, the back-end will filter it to the front-end
If there are too many useless ones, you may have to spell json by yourself.
You can discuss with the backend and conditionally determine which data to return based on the tag parameters passed from the front end. Reduce network data transmission and so on.