write a hugo page that displays a json file as a table with markdown
- User
write a hugo page that displays a json file as a table with markdown
Assistant
Here is a Hugo page that displays a JSON file as a Markdown table:
--- title: "JSON Table" date: 2020-01-01T00:00:00Z --- {{ $data := getJSON "data.json" }} | Name | Age | Occupation | |:-:|:-:|:-:| {{ range $key, $value := $data }} | {{ $value.Name }} | {{ $value.Age }} | {{ $value.Occupation }} | {{ end }}This page:
- Gets the data from data.json using the getJSON shortcode
- Loops through each object in the JSON data
- Renders a row in the Markdown table for each object, using the values for Name, Age and Occupation
- The end result is a nicely formatted Markdown table displaying the data from the JSON file
So if data.json contained this:
[ { "Name": "John", "Age": 30, "Occupation": "Software Engineer" }, { "Name": "Jane", "Age": 25, "Occupation": "Designer" } ]
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.