• Confluence is currently running with all non-system plugins disabled, some functionality may be missing

Page tree

With recent version of ConfiDoc, 3.5.0, we have extensively expanded support for accessing the data from JSON right inside the ConfiDoc fields.

Below, please find couple of examples


Accessing values of a single element arrays

{
  "query": "IS",
  "result": [
    {
      "id": [
        "378"
      ],
      "lastModificationUser": [
        "sash"
      ],
      "description": [
        "my super tool"
      ],
      "name": [
        "the name of app"
      ],
      "lastModificationTime": [
        "2016-10-25T08:30:46.557+0200"
      ]
    }
  ]
}

As you can see, all the values, for unknown reasons, are wrapped into arrays.

Before 3.5.0 version, ConfiDoc was able to output the values only in the format like this ["sash"] (when accessing it through result.lastModificationUser)

But now, the value is recognized as a single value array and teh text value get's nicely extracted from the JSON, producing the sash as a result


Accessing values from array of the arrays

{
 "range": "Summary!A1:C2",
 "majorDimension": "ROWS",
 "values": [
  [
   "Area",
   "Count",
   "Avg"
  ],
  [
   "My Department",
   "16",
   "4.75"
  ]
 ]
}

To access the value 4.75 you will need to write the following expression into a ConfiDoc field name parameter

values[1][2]


How to translate this? We ask ConfiDoc to get the row with index 1 (arrays indeces start with 0) and tell to pick the 3rd element (again, the index starts from 0, and theerfore the index value is 2 here, for element number 3)

To give another example - to access "Count" value you will need to write values[0][1]


Accessing elements by attribute values (based on Riada Insight object JSON)

{
 "id": 1,
 "label": "testio",
 "name": "testio",
 "objectKey": "IT-1",
 "avatar": {
  "url16": "http://localhost:2990/jira/plugins/servlet/com.riadalabs.jira.plugins.insight/icon.png?id=141&size=16",
  "url48": "http://localhost:2990/jira/plugins/servlet/com.riadalabs.jira.plugins.insight/icon.png?id=141&size=48",
  "url72": "http://localhost:2990/jira/plugins/servlet/com.riadalabs.jira.plugins.insight/icon.png?id=141&size=48",
  "url144": "http://localhost:2990/jira/plugins/servlet/com.riadalabs.jira.plugins.insight/icon.png?id=141&size=48",
  "url288": "http://localhost:2990/jira/plugins/servlet/com.riadalabs.jira.plugins.insight/icon.png?id=141&size=48",
  "objectId": 1
 },
 "objectType": {
  "id": 12,
  "name": "Application",
  "type": 0,
  "description": "",
  "icon": {
   "id": 141,
   "name": "Application",
   "url16": "http://localhost:2990/jira/plugins/servlet/com.riadalabs.jira.plugins.insight/icon.png?id=141&size=16&inherited=false&abstract=false",
   "url48": "http://localhost:2990/jira/plugins/servlet/com.riadalabs.jira.plugins.insight/icon.png?id=141&size=48&inherited=false&abstract=false"
  },
  "position": 6,
  "objectCount": 0,
  "parentObjectTypeId": 5,
  "objectSchemaId": 1,
  "inherited": false,
  "abstractObjectType": false,
  "parentObjectTypeInherited": false
 },
 "created": "12/Dec/17 12:06 PM",
 "updated": "12/Dec/17 12:20 PM",
 "hasAvatar": false,
 "timestamp": 1513074005763,
 "attributes": [
  {
   "id": 1,
   "objectTypeAttribute": {
    "id": 45,
    "name": "Key",
    "label": false,
    "type": 0,
    "defaultType": {
     "id": 0,
     "name": "Text"
    },
    "editable": false,
    "system": true,
    "sortable": true,
    "summable": false,
    "minimumCardinality": 0,
    "maximumCardinality": 1,
    "removable": false,
    "hidden": false,
    "includeChildObjectTypes": false,
    "uniqueAttribute": false,
    "options": "",
    "position": 0
   },
   "objectTypeAttributeId": 45,
   "objectAttributeValues": [
    {
     "value": "IT-1"
    }
   ],
   "objectId": 1,
   "position": 0
  },
  {
   "id": 4,
   "objectTypeAttribute": {
    "id": 46,
    "name": "Name",
    "label": true,
    "type": 0,
    "defaultType": {
     "id": 0,
     "name": "Text"
    },
    "editable": true,
    "system": false,
    "sortable": true,
    "summable": false,
    "minimumCardinality": 1,
    "maximumCardinality": 1,
    "removable": false,
    "hidden": false,
    "includeChildObjectTypes": false,
    "uniqueAttribute": false,
    "options": "",
    "position": 1
   },
   "objectTypeAttributeId": 46,
   "objectAttributeValues": [
    {
     "value": "testio app"
    }
   ],
   "objectId": 1,
   "position": 1
  },
  {
   "id": 2,
   "objectTypeAttribute": {
    "id": 47,
    "name": "Created",
    "label": false,
    "type": 0,
    "defaultType": {
     "id": 6,
     "name": "DateTime"
    },
    "editable": false,
    "system": true,
    "sortable": true,
    "summable": false,
    "minimumCardinality": 0,
    "maximumCardinality": 1,
    "removable": false,
    "hidden": false,
    "includeChildObjectTypes": false,
    "uniqueAttribute": false,
    "options": "",
    "position": 2
   },
   "objectTypeAttributeId": 47,
   "objectAttributeValues": [
    {
     "value": "12/Dec/17 12:06 PM"
    }
   ],
   "objectId": 1,
   "position": 2
  }
 ],
 "extendedInfo": {
  "openIssuesExists": false,
  "attachmentsExists": false
 },
 "_links": {
  "self": "http://localhost:2990/jira/secure/ShowObject.jspa?id=1"
 }
}

what if we want to show the value of a particular element from the array of attributes, for example

"value": "testio app"

As you can see, the document contains an array of attributes, each with the same structure.

In ConfiDoc version 3.5.0 and later we now can put the following into a ConfiDoc Field name parameter to extract a value of a matching node:

attributes.objectTypeAttribute(objectTypeAttributeId=46).objectAttributeValues.value

So, it tells ConfiDoc to go through the attributes array, and match the objectTypeAttribute element with a key  objectTypeAttributeId having a value 46, then get it's values via objectattributeValues and get the "value" element


  • No labels