ods icon indicating copy to clipboard operation
ods copied to clipboard

Adapter returns stringified array

Open MBuchalik opened this issue 5 years ago • 4 comments

When requesting data using the Adapter, we get a response like this:

{"id":1234,"data":"[{\"column1\":\"first\",\"column2\":\"second\",\"column3\":\"third\"}]"}

Expected result:

The "data" field should be an actual array.

{
  "id":1234,
  "data": [
    {"column1":"first","column2":"second","column3":"third"}
  ]
}

Actual result

The "data" field is currently a string. So you need to run JSON.parse() in order to get the actual data.

MBuchalik avatar Dec 15 '20 11:12 MBuchalik

What exact endpoint are you using?

sonallux avatar Dec 15 '20 11:12 sonallux

I am using the "preview" endpoint (api/adapter/preview). But it seems like it also happens with api/adapter/dataImport?includeData=true

MBuchalik avatar Dec 15 '20 11:12 MBuchalik

Well, this is currently somehow by design (our internal events use this format too) and also because the Adapter is written in Java. As Java and JPA do not natively support JSON, we are storing the data as String internally, which is not ideal but simple.

Might be worth keeping this in mind when we are discussing #283 in the next meeting.

sonallux avatar Dec 15 '20 12:12 sonallux

Exactly, we stored the data as a string because this was the simplest solution regarding persistence. I also think that we should discuss this in the developer meeting. However, I think we should keep it separate from #283.

mathiaszinnen avatar Dec 16 '20 19:12 mathiaszinnen