jvalue / ods

Open Data Service - Make consuming open data easy, safe, and reliable
GNU Affero General Public License v3.0
36 stars 23 forks source link

Adapter returns stringified array #291

Open MBuchalik opened 3 years ago

MBuchalik commented 3 years ago

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.

sonallux commented 3 years ago

What exact endpoint are you using?

MBuchalik commented 3 years ago

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

sonallux commented 3 years ago

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.

mathiaszinnen commented 3 years ago

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.