How to convert JSON format to String format

Hi All,

I have requirement which i need to convert below mentioned JSON format to..

{
  "requestId": "221a0000-faff-00e3-ac11-dbe6ebd00d00",
  "sourceSystemName": "ABCD",
  "requestDateTime": "2023-08-23T15:03:31.919Z",
  "requestInitiator": "App Name",
  "context": "/fetchData",
  "data": {
    "kind": "fetchDataRequest",
    "items": [
      {
        "item": {
          "key": "ID",
          "value": [
            "1234567890"
          ]
        }
      },
      {
        "item": {
          "key": "CRITERIA",
          "value": [
            "EMPLOYEEDETAILS",
            "INCLUDEIDDETAILS"
          ]
        }
      }
    ]
  }
}

.. this string format:

"{
""requestId"": ""221a0000-faff-00e3-ac11-dbe6ebd00d00"",
""sourceSystemName"": ""ABCD"",
""requestDateTime"": ""2023-08-23T15:03:31.919Z"",
""requestInitiator"": ""App Name"",
""context"": ""/fetchData"",
""data"": {
""kind"": ""fetchDataRequest"",
""items"": [
{
""item"": {
""key"": ""ID"",
""value"": [
""1234567890""
]
}
},
{
""item"": {
""key"": ""CRITERIA"",
""value"": [
""EMPLOYEEDETAILS"",
""INCLUDEIDDETAILS""
]
}
}
]
}
}"

How to achieve this? After converting i need to pass in Request Body of integration to get data.

Regards,
Sandeep

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Hi David,

    Please refer to this code, this is same which i have shared in above conversation.
    I need to dynamically create below mentioned parameters values which are:
    1. Create UUID for requestId parameter.
    2. ID need to pass dynamically

    Later that this entire JSON code i need to convert as String in order to pass in Request body for getting Coverage data.

    {
      "requestId": "221a0000-faff-00e3-ac11-dbe6ebd00d00",
      "sourceSystemName": "ABCD",
      "requestDateTime": "2023-08-23T15:03:31.919Z",
      "requestInitiator": "App Name",
      "context": "/fetchData",
      "data": {
        "kind": "fetchDataRequest",
        "items": [
          {
            "item": {
              "key": "ID",
              "value": [
                "1234567890"
              ]
            }
          },
          {
            "item": {
              "key": "CRITERIA",
              "value": [
                "EMPLOYEEDETAILS",
                "INCLUDEIDDETAILS"
              ]
            }
          }
        ]
      }
    }

    Regards,
    Sandeep