Skip to main content
April 13, 2024
Question

How to convert JSON format to String format

  • April 13, 2024
  • 8 replies
  • 0 views

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
    April 13, 2024

    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

    April 13, 2024

    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
    April 13, 2024

    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
    April 13, 2024

    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

    April 14, 2024

    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