# Logic within json

**URL:** <https://forum.inductiveautomation.com/t/logic-within-json/75064>\
**Category:** Ignition\
**Tags:** ignition81, perspective, scripting\
**Created:** [June 15, 2023, 9:12am UTC](https://forum.inductiveautomation.com/t/logic-within-json/75064 "2023-06-15T09:12:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hans\_odgaard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hans_odgaard/32/83110_2.png) [@hans\_odgaard](https://forum.inductiveautomation.com/u/hans_odgaard)\
**Post date:** [June 15, 2023, 9:12am UTC](https://forum.inductiveautomation.com/t/logic-within-json/75064/1 "2023-06-15T09:12:54Z")

</div>

Is it possible to add some logic in one of the fields  
This script loops through my dataset and creates all the columns based on my headers in the dataset.  
But I would like to be able to change the Title based on my header Value,

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/9/d9c2e8f537d42c07dd578e9a93dfe436de5c1c36.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/d/fd05e8cf6cf85290d7bc95e0a2ea8010401c76cd.png)

```
headers = value.getColumnNames()
true=True
false = False

return [ {
  "field": header,
  "visible": true,
  "editable": false,
  "render": "auto",
  "justify": "auto",
  "align": "center",
  "resizable": true,
  "sortable": true,
  "sort": "none",
  "filter": {
    "enabled": false,
    "visible": "on-hover",
    "string": {
      "condition": "",
      "value": ""
    },
    "number": {
      "condition": "",
      "value": ""
    },
    "boolean": {
      "condition": ""
    },
    "date": {
      "condition": "",
      "value": ""
    }
  },
  "viewPath": "",
  "viewParams": {},
  "boolean": "checkbox",
  "number": "value",
  "progressBar": {
    "max": 100,
    "min": 0,
    "bar": {
      "color": "",
      "style": {
        "classes": ""
      }
    },
    "track": {
      "color": "",
      "style": {
        "classes": ""
      }
    },
    "value": {
      "enabled": true,
      "format": "0,0.##",
      "justify": "center",
      "style": {
        "classes": ""
      }
    }
  },
  "toggleSwitch": {
    "color": {
      "selected": "",
      "unselected": ""
    }
  },
  "nullFormat": {
    "includeNullStrings": false,
    "strict": false,
    "nullFormatValue": ""
  },
  "numberFormat": "0,0.##",
  "dateFormat": "YYYY-MM-DD HH:mm:ss",
  "width": "",
  "strictWidth": false,
  "style": {
    "classes": ""
  },
  "header": {
    "title": "",
    "justify": "left",
    "align": "center",
    "style": {
      "classes": ""
    }
  },
  "footer": {
    "title": "",
    "justify": "left",
    "align": "center",
    "style": {
      "classes": ""
    }
  }
} for header in headers ]

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 15, 2023, 9:31am UTC](https://forum.inductiveautomation.com/t/logic-within-json/75064/2 "2023-06-15T09:31:49Z")

</div>

This is not json, this is a python dict. You can do whatever you want that's allowed by python.

```python
return [
    {
        'header': {
            'title': header.title().replace('_', ' ').whateveryouwant()
        }
    } for header in headers
]

```

> [@hans\_odgaard](#):
>
> ```python
> true=True
> false = False
> 
> ```

Why ?

---

<div class="post-metadata">

**Author:** ![hans\_odgaard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hans_odgaard/32/83110_2.png) [@hans\_odgaard](https://forum.inductiveautomation.com/u/hans_odgaard)\
**Post date:** [June 15, 2023, 10:17am UTC](https://forum.inductiveautomation.com/t/logic-within-json/75064/3 "2023-06-15T10:17:47Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/5/95b3bb6d5e3930ee13b5ff19c92eeebe62ffd1e9.png)  
That's why,  
I haven't tested by simply replacing them, here I could simply copy paste the column setup from the table

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 15, 2023, 10:26am UTC](https://forum.inductiveautomation.com/t/logic-within-json/75064/4 "2023-06-15T10:26:06Z")

</div>

A tip for next time: You don't need to paste the whole thing, only the properties you want to change.  
The other ones will just use the defaults.

---

<div class="post-metadata">

**Author:** ![hans\_odgaard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hans_odgaard/32/83110_2.png) [@hans\_odgaard](https://forum.inductiveautomation.com/u/hans_odgaard)\
**Post date:** [June 15, 2023, 10:29am UTC](https://forum.inductiveautomation.com/t/logic-within-json/75064/5 "2023-06-15T10:29:14Z")

</div>

Yes you are right but I always come up with a new idea or someone wants the data presented in another way me or can you change that.  
So for me it works better with the whole structure from the start
