Home > Mobile >  How to read data from mongo query result as Json Format in WSo2 Integration Studio Data Service Proj
How to read data from mongo query result as Json Format in WSo2 Integration Studio Data Service Proj

Time:01-16

I created mongo database as data service in Integration Studio. I want to call a query from Mongo and read its result as Json. I am trying below method but data is coming as null. I want to read the data returned by Mongo in json format. Can you help with this ?

The Code for Integration Studio Data service xml:

enter image description here

Data returned by MongoDb Query:

[
  {
    "_id": {
      "id": "1234",
      "type": "test"
    }
  }
]

CodePudding user response:

Update your output mappings to the following.

{
  "Documents": {
    "Document": [
      {
        "id": "$document._id.id",
        "name": "$document._id.type"
      }
    ]
  }
}

  • Related