# Convert Dictionary to string array DataType

**URL:** <https://forum.inductiveautomation.com/t/convert-dictionary-to-string-array-datatype/20771>\
**Category:** Ignition\
**Created:** [November 12, 2018, 5:16pm UTC](https://forum.inductiveautomation.com/t/convert-dictionary-to-string-array-datatype/20771 "2018-11-12T17:16:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [November 12, 2018, 5:16pm UTC](https://forum.inductiveautomation.com/t/convert-dictionary-to-string-array-datatype/20771/1 "2018-11-12T17:16:39Z")

</div>

I have the dictionary (Example below),

```auto
{'TS1 dNm': '0.48', 'TC90-TC10': '0.57', 'I-Filter': '6.00', 'TS2 dNm': '0.63', 'T90': '0.94', 'T50': '0.59', 'Test Time': '3.00', 'Torque Range': '8.0', 'T60': '0.66', 'T30': '0.49', 'T40': '0.54', 'T10': '0.38', 'crazy result': '10.27', 'Test Temp': '145.00', 'T25': '0.46', 'Max Rate': '7.05', 'tanD@ML': '0.571', 'MH': '5.80', 'tanD@MH': '0.308', 'ML': '2.24'}

```

I have to write these values to the tag where I want to interpret it and assign to various tags.

I tried creating the string array type tag and putting these values into it but it would pop up the conversion error.

How do we write this dictionary to tag (which datatype could be used. Perhaps, converting into the list is an option)?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 12, 2018, 5:26pm UTC](https://forum.inductiveautomation.com/t/convert-dictionary-to-string-array-datatype/20771/2 "2018-11-12T17:26:28Z")

</div>

You could use system.util.jsonEncode, as long as you can guarantee that the values in the dictionary are also primitives (numbers, strings, etc).

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [November 12, 2018, 5:48pm UTC](https://forum.inductiveautomation.com/t/convert-dictionary-to-string-array-datatype/20771/3 "2018-11-12T17:48:21Z")

</div>

what about having

```auto
":" and "'" and "," ?

```

cause these are not primitive values.

I tried with system.util.jsonEncode but it’s giving me the same error.

Note : The data is same as described in question.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 12, 2018, 6:38pm UTC](https://forum.inductiveautomation.com/t/convert-dictionary-to-string-array-datatype/20771/4 "2018-11-12T18:38:57Z")

</div>

If you’re just wanting to make a couple of lists:

```python
dictIn = {'TS1 dNm': '0.48', 'TC90-TC10': '0.57', 'I-Filter': '6.00', 'TS2 dNm': '0.63', 'T90': '0.94', 'T50': '0.59', 'Test Time': '3.00', 'Torque Range': '8.0', 'T60': '0.66', 'T30': '0.49', 'T40': '0.54', 'T10': '0.38', 'crazy result': '10.27', 'Test Temp': '145.00', 'T25': '0.46', 'Max Rate': '7.05', 'tanD@ML': '0.571', 'MH': '5.80', 'tanD@MH': '0.308', 'ML': '2.24'}
keyList = dictIn.keys()
valueList = [dictIn[key] for key in keyList]

```

While:

```auto
valueList = dictIn.values()

```

looks like it would work, I prefer to be certain of the 1:1 parity to the keys. Dictionaries sometimes do screwy things. Usually at unexpected times…
