node-csvtojson icon indicating copy to clipboard operation
node-csvtojson copied to clipboard

Incoherent processing of nested data with arrays and non-arrays

Open mebibou opened this issue 1 year ago • 0 comments

There is an incoherent processing of the following data:

Case 1:

test.id,test.values.value,test.values.0.id
1,foo,bar

which converts to:

[
  {
    "test": {
      "id": "1",
      "values": {
        "0": {
          "id": "bar"
        },
        "value": "foo"
      }
    }
  }
]

Case 2:

test.id,test.values.0.id,test.values.value
1,bar,foo

which converts to:

[
  {
    "test": {
      "id": "1",
      "values": [
        {
          "id": "bar"
        }
      ]
    }
  }
]

Those 2 CSV are basically the same, I only inverted column 2 and 3, and it gives different result. It seems because the array is parsed first, test.values.value is simply being ignored

mebibou avatar Aug 27 '24 09:08 mebibou