Skip to main content
Known Participant
Apr 13, 2024 10:07 AM UTC
Question

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

    8 replies

    karumurua531442
    Participating Frequently
    Apr 13, 2024 10:09 AM UTC

    hi [mention:a0cb9d1f6c284d9f8075981e0d6bdf8c:e9ed411860ed4f2ba0265705b8793d05]  You can use a!fromJson() function check please, click on the link for more details regarding that function, Please let me know if it is working

    Known Participant
    Apr 13, 2024 10:20 AM UTC

    Thanks Abhishek,

    Tried to wrap entire JSON format in a!fromJson() function getting below mentioned syntax error:

    Expression evaluation error: Syntax error. Details: Expression evaluation error at function a!fromJson parameter 1 [line 9]: Invalid symbol found (open_bracket)

    Screenshot for reference:
    [View:/cfs-file/__key/communityserver-discussions-components-files/18/Test-screenshot.docx:320:240]

    Regards,
    Sandeep

    karumurua531442
    Participating Frequently
    Apr 13, 2024 10:41 AM UTC

    Hi [mention:a0cb9d1f6c284d9f8075981e0d6bdf8c:e9ed411860ed4f2ba0265705b8793d05]  could you try this code, This code converts json data to string

    touniformstring(
      a!fromJson(
      "
    {
    ""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""]
    }
    }
    ]
    }
    }
    "
    ))
    

    mathieud0001
    Genius
    Apr 13, 2024 1:36 PM UTC

    Not sure why you want to double the quotes, but couldn't you just use the substitute function?

    docs.appian.com/.../fnc_text_substitute.htm

    Known Participant
    Apr 14, 2024 6:47 PM UTC

    Hi Drouin,

    I need to convert as String with double the quotes which i need to to pass in Request body for getting Coverage data.

    If possible share here any sample example for substitue function, so that i will try to configure for the above JSON.


    Regards,
    Sandeep