# DataModel does not properly restore String array

**URL:** <https://forum.universal-robots.com/t/datamodel-does-not-properly-restore-string-array/5446>\
**Category:** URCap Development\
**Tags:** datamodel\
**Created:** [October 29, 2019, 10:10am UTC](https://forum.universal-robots.com/t/datamodel-does-not-properly-restore-string-array/5446 "2019-10-29T10:10:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon75497214](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@anon75497214](https://forum.universal-robots.com/u/anon75497214)\
**Post date:** [October 29, 2019, 10:10am UTC](https://forum.universal-robots.com/t/datamodel-does-not-properly-restore-string-array/5446/1 "2019-10-29T10:10:49Z")

</div>

I noticed that the datamodel does not properly restore a string array.  
If an entry of an array contains a comma, that entry is split up.

This caused a lot of problems for us. We now try to avoid commas but it is not an ideal situation.

I am building against the 1.5.0 sdk and here is example code that demonstrates this behaviour:

```java
        String [] testArr = {"one, two", "three, four", "five, six"};
        System.out.println("array length: " + testArr.length);
        for (String s: testArr) {
            System.out.println("entry: " + s);
        }
        /*
        array length: 3
        entry: one, two
        enty: three, four
        entry: five, six
        */

        model.set("test", testArr);
        String[] outArr = model.get("test", new String[0]);
        System.out.println("array length: " + outArr.length);
        for (String s: outArr) {
            System.out.println("entry: " + s);
        }
        /*
        array length: 6
        entry: one
        entry: two
        entry: three
        entry: four
        entry: five
        entry: six
        */

```

---

<div class="post-metadata">

**Author:** ![anon75497214](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@anon75497214](https://forum.universal-robots.com/u/anon75497214)\
**Post date:** [November 13, 2019, 5:02pm UTC](https://forum.universal-robots.com/t/datamodel-does-not-properly-restore-string-array/5446/2 "2019-11-13T17:02:37Z")

</div>

Hello? Any feedback here from UR? Is this a feature @jbm ?

---

<div class="post-metadata">

**Author:** ![Ebbe](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ebbe/32/1413_2.png) [@Ebbe](https://forum.universal-robots.com/u/Ebbe)\
**Post date:** [November 14, 2019, 8:02pm UTC](https://forum.universal-robots.com/t/datamodel-does-not-properly-restore-string-array/5446/3 "2019-11-14T20:02:56Z")

</div>

Hi Raphael,

Thank you for the detailed description. I will look into the issue!

---

<div class="post-metadata">

**Author:** ![anon75497214](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@anon75497214](https://forum.universal-robots.com/u/anon75497214)\
**Post date:** [January 2, 2020, 3:35pm UTC](https://forum.universal-robots.com/t/datamodel-does-not-properly-restore-string-array/5446/4 "2020-01-02T15:35:10Z")

</div>

Is there an update on this?

We also found that when we save a string array that only contains **one** empty string and retrieve it, we get an empty array back. When saving a string array with two empty strings for example we get the correct values back. This was very annoying to debug.

---

<div class="post-metadata">

**Author:** ![felix.green](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/felix.green/32/6215_2.png) [@felix.green](https://forum.universal-robots.com/u/felix.green)\
**Post date:** [September 26, 2024, 7:25pm UTC](https://forum.universal-robots.com/t/datamodel-does-not-properly-restore-string-array/5446/5 "2024-09-26T19:25:22Z")

</div>

Amazing to find the very same issue 5 years later.

I blew my afternoon away on this problem (hunting down StackOverflow issues) and only just discovered it was our array of JointPositions converted to strings that was causing the issue.

Funny enough, this issue only presents itself with both a comma AND a space.

So the way to fix the problem is to remove the space after the comma. This will work for you:

`String [] testArr = {"one,two", "three,four", "five,six"};`

(My guess is that UR is converting all arrays to strings under the hood, and then using COMMA SPACE as the delimiters for it.)
