How to turn Json data into a table in page

Hello,
I have a beginner’s question because I don’t understand how to do this. I’m trying to interpret a json so that it appears formatted in HTML.
I thought that all I had to do was paste my json into a page and create an item.json.twig for it to work?
I’d like an HTML page as a result instead of the json interpretation.
How do I go about it?
Thank you very much for your help

@longh, Surround the json in your markdown with triple backticks, like:

```
{
  "name": "Name of user"
}
```

This which will show as:

{
  "name": "Name of user"
}

No need to use a item.json.twig

thanks for the reply but I’ve mistranslated my request?

I would like to put a json in the backoffice in edit page and get HTML in the frontpage.

@longh, Please provide more details:

  • What does the json look like?
  • What do you expect to see in the front-end?
  • What do you see instead?

i would like :

My result is a json file

@longh, That information is quite different from the original question…
Update: I’ve taken the liberty to alter the title

Try plugins “Table Importer”

The Table Importer Plugin is for Grav CMS. It imports tables from JSON, YAML, and CSV formats into a page.

And/or plugin Import:

This plugin allows you to import YAML and JSON files into the header of your pages, facilitating custom actions/settings.

Note:

  • Both plugins are abandoned.
  • I have no experience with either of the two.

Update: Plugin Table Importer is going to be taken over by new maintainer.

I was going to mention the table importer plugin as well to accomplish what you are trying to do @longh. The only caveat here is that your JSON content is attached to the page as a file and not embedded in the page content

I am working to get it updated to work correctly with Grav 1.7 and PHP 8 right now. I plan to have a release out later this week.

2 Likes