Convert JSON to CDT

Hello everyone, I have a process model that is using a custom smart service to perform web service calls. The below json is the response I'm getting. I need to store these results into a database table. Please provide me some guidance on what would be the best approach on parsing this json string into a CDT.

{
  "id":"123",
  "status": "working",
  "reports":[
                 {
                     "name": "report1",
                     "status": "complete",
                     "_links": [
                                 {
                                     "type": "csv",
                                     "href": "http://..../report1.csv"
                                  }
                     ]
                  },
                  {
                     "name": "report2",
                     "status": "errored",
                     "reason": "Something horrible occurred..."
                     "_links": [
                     ]
                  },
                  {
                      "name": "report3",
                       "status": "working",
                       "_links": [
                       ]
                   },
                   {
                       "name": "report4",
                       "status": "pending",
                       "_links": [
                       ]
                    },
  ]
}

Thank you!

  Discussion posts and replies are publicly visible

Parents
  • do the following:
    local!fromArray: a!fromJson({
    "id":"123",
    "status": "working",
    "reports":[
    {
    "name": "report1",
    "status": "complete",
    "_links": [
    {
    "type": "csv",
    "href": "http://..../report1.csv"
    }
    ]
    },
    {
    "name": "report2",
    "status": "errored",
    "reason": "Something horrible occurred..."
    "_links": [
    ]
    },
    {
    "name": "report3",
    "status": "working",
    "_links": [
    ]
    },
    {
    "name": "report4",
    "status": "pending",
    "_links": [
    ]
    },
    ]
    }),

    local!cdtData: a!forEach(items: local!fromArray, expression:{'type!{namespace}CDT(col1: fv!items[fv!index].col1, col2:fv!items[fv!index].col2, col3:fv!items[fv!index].col3, col4:fv!items[fv!index].col4,...etc),)
Reply
  • do the following:
    local!fromArray: a!fromJson({
    "id":"123",
    "status": "working",
    "reports":[
    {
    "name": "report1",
    "status": "complete",
    "_links": [
    {
    "type": "csv",
    "href": "http://..../report1.csv"
    }
    ]
    },
    {
    "name": "report2",
    "status": "errored",
    "reason": "Something horrible occurred..."
    "_links": [
    ]
    },
    {
    "name": "report3",
    "status": "working",
    "_links": [
    ]
    },
    {
    "name": "report4",
    "status": "pending",
    "_links": [
    ]
    },
    ]
    }),

    local!cdtData: a!forEach(items: local!fromArray, expression:{'type!{namespace}CDT(col1: fv!items[fv!index].col1, col2:fv!items[fv!index].col2, col3:fv!items[fv!index].col3, col4:fv!items[fv!index].col4,...etc),)
Children
No Data