# YAML variable type

**URL:** <https://forum.robotframework.org/t/yaml-variable-type/9526>\
**Category:** Robot Framework\
**Created:** [28 January 2026 13:44 UTC](https://forum.robotframework.org/t/yaml-variable-type/9526 "2026-01-28T13:44:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![FNour](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/fnour/32/5076_2.png) [@FNour](https://forum.robotframework.org/u/FNour)\
**Post date:** [28 January 2026 13:44 UTC](https://forum.robotframework.org/t/yaml-variable-type/9526/1 "2026-01-28T13:44:41Z")

</div>

i am using robot framework version=7.4

i want to access the values in a nested dictionary,  
for example it is:  
ret = [0, {‘2’: {‘data’: [1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18], ‘min’: 1.18, ‘max’: 1.18}, ‘3’: {‘data’: [1.19, 1.19, 1.19, 1.19, 1.19, 1.19, 1.19, 1.19, 1.19, 1.19, 1.19], ‘min’: 1.19, ‘max’: 1.19}, ‘0’: {‘data’: [1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18], ‘min’: 1.18, ‘max’: 1.18}}]  
—————————————————————————————————————

i am using variable.yaml that is imported in \*\*\*_ **setting** _\*\*\* :

_`Variables`_` variable.yaml`

the yaml is:

```yaml
SPK:
  RR_P:
    FI: 0 
    AI: 0
  FR_P:
    FI: 2
    AI: 2
  FL_P:
    FI: 1
    AI: 1
  RL_P:
    FI: 3
    AI: 3

```

the below code fails:

`Log To Console ${ret[1]}[${SPK.FR_P.AI}]`

error: Dictionary ‘${ret[1]}’ has no key ‘2’

* * *

the below code also fails:

_`Log To Console`_` ${ret[1]}['${SPK.FR_P.AI}']`

Dictionary ‘${ret[1]}’ has no key ‘‘2’’

* * *

but the below code pass:

```python
${a} Convert To String ${SPK.FR_P.AI}

 Log To Console ${ret[1]}[${a}]

```

{‘data’: [1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18], ‘min’: 1.18, ‘max’: 1.18}

* * *

but the below code pass:

_`Log To Console`_` ${ret[1]}[2]`

{‘data’: [1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18, 1.18], ‘min’: 1.18, ‘max’: 1.18}

```bash

```

- what is difference? What is the type of variable from YAML in robot view?

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [28 January 2026 14:24 UTC](https://forum.robotframework.org/t/yaml-variable-type/9526/2 "2026-01-28T14:24:49Z")

</div>

> [@FNour](#):
>
> what is difference? What is the type of variable from YAML in robot view?

There is not that concept. Variables are Python variables, dictionaries in this case. If it was JSON, they should be Python variables still.

Maybe your YAML data is not correct, try adding more identation:

```python
  SPK:
    RR_P:
        FI: 0 
        AI: 0
    FR_P:
        FI: 2
        AI: 2
    FL_P:
        FI: 1
        AI: 1
    RL_P:
        FI: 3
        AI: 3

```

---

<div class="post-metadata">

**Author:** ![FNour](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/fnour/32/5076_2.png) [@FNour](https://forum.robotframework.org/u/FNour)\
**Post date:** [29 January 2026 06:16 UTC](https://forum.robotframework.org/t/yaml-variable-type/9526/3 "2026-01-29T06:16:32Z")

</div>

> [@FNour](#):
>
> [‘${SPK.FR\_P.AI}’]

Thanks,

the question is what is difference between `Convert to String` keyword and when we add `‘ ‘` in [‘${SPK.FR\_P.AI}’] ?

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [29 January 2026 12:05 UTC](https://forum.robotframework.org/t/yaml-variable-type/9526/4 "2026-01-29T12:05:07Z")

</div>

I created example test suite with your data. At first I noticed that the dictionary `ret` was using wrong quotes. Maybe you are using a MacOS with quotes decoration.

Here are the data files and test suite:  
[ret\_data.py](https://forum.robotframework.org/uploads/short-url/82U9tzUFf2wwXdL2FTLmXIwIIpC.py) (338 Bytes)  
[YAML\_Test\_data.robot](https://forum.robotframework.org/uploads/short-url/7EcfsgF7wCDlkNmyZz7rr0RtYjH.robot) (1.7 KB)

`data.yaml`

```python
SPK:
  RR_P:
    FI: 0 
    AI: 0
  FR_P:
    FI: 2
    AI: 2
  FL_P:
    FI: 1
    AI: 1
  RL_P:
    FI: 3
    AI: 3

```

It is really a complicated issue, because sometimes we use dictionary `keys` and other times `indexes`.

Maybe @pekkaklarck can clarify this.

---

<div class="post-metadata">

**Author:** ![pekkaklarck](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/pekkaklarck/32/1019_2.png) [@pekkaklarck](https://forum.robotframework.org/u/pekkaklarck)\
**Post date:** [2 February 2026 17:44 UTC](https://forum.robotframework.org/t/yaml-variable-type/9526/5 "2026-02-02T17:44:41Z")

</div>

The problem seems to be that `${SPK.FR_P.AI}` is integer `2`, but your dictionary has string `2` as a key.

> [@FNour](#):
>
> the question is what is difference between `Convert to String` keyword and when we add `‘ ‘` in [‘${SPK.FR\_P.AI}’] ?

`Convert to String` converts the value to a string and later when you use `${dict}[${string}]` everything works fine. When you use `${dict}["${integer}"]`, the used key will contain the quotes and in your case be literal `"2"`.

I don’t think we can change Robot to make this work. It would be somewhat magic that if you access a dictionary with an integer, we’d try it also with a string. You can, however, easily change your YAML file so that values are strings, not integers. Just change, for example, `AI: 2` to `AI: "2"`.
