Suitable web structure for compiling JSON data in HTML

I am looking for a good web framework for compiling multiple JSON sources received with HTTP requests into static HTML. I do not want to do this on the client side (browser, javascript), I am looking for the best server solution.

So, I need to do the following:

  • Get several different JSON documents via HTTP
  • Format JSON as HTML content, mainly with templates, but with some dynamic custom HTML
  • Basic setup of input / output / settings, nothing significant
  • Stateless home pages what state is, comes already in JSON
  • Search / Friendly URLs; should be fine-tuned

How I would like to do this:

  • A quick fix, perhaps just a template engine
  • HTML templates that do not have custom syntax over HTML / XML, such as Wicket and almost like Tapestry
  • An application server that scales and uses multiple processors properly (for example, one Python process is not working)
  • Java is preferable, but if Java has nothing suitable to consider others.

As for the template part, if it were in JavaScript in the browser, then something like PURE would be my tool of choice.

+4
source share
2 answers

You might want to check out RESTx . It is an open source platform for easily creating RESTful resources. It allows you to write custom data access and integration logic in Java or Python. Getting data from several sources and combining it is what it was done for, so it should be very close. Data output is made in accordance with the user's request. For example, another JSON data source or the same data as in HTML.

HTML rendering currently matches the inline template. However, this should be fairly easy to modify. I am one of the developers of this project, so if you need special features of the template, let me know and I will see what I can do.

To give you an example: suppose you have two JSON resources, you would write it in your code (I gave a Python example here, but a Java example would look very similar):

status, data_1 = accessResource("/resource/some_resource") status, data_2 = accessResource("/resource/some_other_resource") # data_1 and data_2 now hold a dictionary, list, etc., depending on the JSON # that was returned. # ... some code that combines and processes the data and produces a dict or list # with the result. The data object you return here is then automatically rendered # in either HTML or JSON, depending on the client request. return Result.ok(data) 

Also consider an example for easy data integration .

+1
source

I think the only structure you need is a library that reads json. Templates can be standard jsp pages.

-1
source

Source: https://habr.com/ru/post/1315374/


All Articles