Add a block of code with terraform in JSON file

I need to add a conditional when the variable is true, add a block of code in my JSON file but if this variable is false, I need it to do nothing

This is my

  resource "grafana_dashboard" "dashboard_test" {
    conficonfig_json = template_file("dashboard.json")
      data_source   = var.data_source

I need add this a block of code in my file JSON

      "datasource": {
          "type": "CloudWatch",
          "uid": "${mystring}"