Data file json question

I’m wondering if I can use a data file to display/chunk a json spec of a product feature, but I’m struggling to figure out how to get my loop to show both the keys and values.

Below is a small sample pipeline spec; pipelines can have a ton of fields:

{
  "transform": {
    "image": "ubuntu:20.04",
    "cmd": [
      "/pach-bin/pachtf",
      "sql-run",
      "snowflake://lb@of28881.us-central1.gcp/ELBY/PUBLIC?warehouse=ELBY",
      "json",
      "select * from pokedex",
      "0000",
      "false"
    ],
    "secrets": [
      {
        "name": "elbypokedexsecret",
        "key": "PACHYDERM_SQL_PASSWORD",
        "envVar": "PACHYDERM_SQL_PASSWORD"
      }
    ]
  },
  "input": {
    "cron": {
      "name": "cron",
      "repo": "elbyPokedex_cron",
      "spec": "@every 5m",
      "overwrite": true,
      "start": {
        "seconds": 1658849922,
        "nanos": 607485096
      }
    }
  },
  "reprocessSpec": "until_success"
}

My idea is to do something like the following:

{{ range $.Site.Data.pipelineSpec }}
   {{ . }} # to see the whole spec as the json exactly, not just the values
{{ end }}

{{ range $.Site.Data.pipelineSpec.transform }}
   {{ . }} # to see the just the transform object and its child keys/values. 
{{ end }}

Is this possible? Thanks

Is pipelineSpec a directory or a file?

It would be a json file with all of the attributes ( it’s a long list). my goal is to selectively display it either fully or partially in docs throughout different pages.

Your example is an object, not an array, so ranging through it doesn’t make sense.

To display the entire object:

<pre>{{ jsonify (dict "indent" "  ") site.Data.pipelineSpec }}</pre>

To display the transform element:

<pre>{{ jsonify (dict "indent" "  ") site.Data.pipelineSpec.transform }}</pre>
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.