Home > front end >  JQ Not Taking In Variable Data
JQ Not Taking In Variable Data

Time:12-24

I am unsuccessfully trying to add variable data to a json within a ci script. I am attempting to use the --arg VariableName VariableData notation.

For example purposes, I am only passing $date which has already been set earlier in the script. In the outputted JSON, the literal string $date is outputted instead of the variable.

jq --arg date "$date" '.sections[0].builds  = [{"title": "Version MyVersion", "timestamp": "$date", "iOS": "My_URL.plist" }]' builds.json > builds1.json

This results in:

{
  "title": "MY Title",
  "columnCount": 1,
  "notes_OFF": "First_Test",
  "sections": [
    {
      "title": "My Title",
      "builds": [
        {
          "title": "Version MyVersion",
          "timestamp": "$date",
          "iOS": "My_URL.plist"
        }
      ]
    }
  ]
}

Original JSON:

{
  "title": "MY Title",
  "columnCount": 1,
  "notes_OFF": "First_Test",
  "sections": [
    {
      "title": "My Title",
      "builds": [
        
      ]
    }
  ]
}

What am I doing wrong here?

CodePudding user response:

Replace "$date" with $date in your filter.

  • Related