Universal Robots Forum

DataModel does not properly restore String array

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:

        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
        */

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

Hi Raphael,

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

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.

1 Like