Hi there!

My team and I are trying to consume a REST API which returns JSON, which OutSystems can't handle out of the box:

An example of this JSON is:


{
  "result": true,
  "message": "export-succes",
  "daterange": "2020-01",
  "exportdata": {
    "1": {
      "bookID": "1",
      "bookTitle": "Book Title Test 1",
      "bookISBN": "0",
      "bookPublisher": "Book Publisher 1",
      "bookAuthor": "Author 2",
      "PublicationState": "free",
      "downloads": 20
    },
    "2": {
      "bookID": "2",
      "bookTitle": "Book Title Test 1",
      "bookISBN": "0",
      "bookPublisher": "Book Publisher 1",
      "bookAuthor": "Author 2",
      "PublicationState": "free",
      "downloads": 10
    },
    "3": {
      "bookID": "3",
      "bookTitle": "Book Title Test 3",
      "bookISBN": "0",
      "bookPublisher": "Book Publisher 1",
      "bookAuthor": "Author 2",
      "PublicationState": "free",
      "downloads": 25
   }
  }
}


We've tried all kinds of ways to deserialize this, but haven't been successful yet.
We also have the ardoJSON forge component yet we don't know how to define our structures so the component is able to deserialize it in the correct way.

eventually, we'd like to end up with a list of a structure containing:
- bookID (text)
- bookTitle (text)
- bookISBN (text)
- bookPublisher (text)
- bookAuthor (text)
- PublicationStat (text)
- downloads (long integer)


I'd greatly appreciate your insights :)

Solution

It's because of the dynamic key "1", "2", "3".

You should strip that or parse it via c# :(

(it's valid yet horrible json )


Solution

Thanks!


After some work, we've been able to use Regex_Replace to convert the JSON into something that's readable, and have been able to deserialize it.

So this one has been resolved :-)