Weird bug on nested property with numeric key

Hello There :slight_smile:

Im using jsonforms 3.2.1 and I’ve just found really weird bug about data saving when property is nested and has some number as a key. I guess its rather rare case, but just wanted to let you know.

Schema:

{
  "type": "object",
  "properties": {
    "group": {
      "type": "object",
      "properties": {
        "15": {
          "type": "string"
        }
      }
    }
  },
  "required": []
}

UISchema:

{
  "type": "VerticalLayout",
  "elements": [
    {
      "type": "Group",
      "label": "Some Group",
      "elements": [
        {
          "type": "Control",
          "label": "Label",
          "scope": "#/properties/group/properties/15"
        }
      ]
    }
  ]
}

With those schema and uischema, when you input something in that field with “15” key - data will look something like that

{
  "group": [
    null, null, null, null, null,
    null, null, null, null, null,
    null, null, null, null, null,
    "something"
  ]
}

I don’t usually use numeric keys, but I had some mocked schema just to test something out with lets say “45012” as a key, so it was pretty interesting in data to see an array with 45013 elements :smile:

Hi @pegu ,
thanks for sharing this! I could reproduce it with latest version 3.4.1. Would you mind creating an issue in the repository at https://github.com/eclipsesource/jsonforms/issues/new?assignees=&labels=&projects=&template=bug_report.yml ?

Thanks,
Lucas

As a guide for a potential fix: I’m pretty sure that is a consequence of lodash set which we are using to update the data, interpreting the “number-string” as an array index.

Hey @lucas-koehler,

I have created the issue :slight_smile:

2 Likes