Expression evaluation error at function a!fromJson: The jsonText parameter was not valid JSON. Received: "{ "formGuid" : "9c35b0af-6d84-47f6-9f57-fb617543e482", "form" : "Apply for margin or option tra...

Please help me to debug it!

I get some JSON data from external sources and save in Database.

I queried on that Database column to get the JSON data in Process Model.Even though there is valid JSON under caseId i am facing this issue..

There are not null values in the JSON.

The JSON under caseID is in code snippet:

 "{   "formGuid" : "9c35b0af-6d84-47f6-9f57-fb617233e482",   "form" : "Apply for margin or option trading - BPM",   "submissions" : [ {     "results" : [ {       "answer" : {         "name" : "Yes",         "id" : "q349.573",         "value" : "false"       }     }, {       "answer" : {         "name" : "No",         "id" : "q349.574",         "value" : "true"       }     }, {       "answer" : {         "name" : "Yes",         "id" : "q348.571",         "value" : "true"       }     }, {       "answer" : {         "name" : "No",         "id" : "q348.572",         "value" : "false"       }     }, {       "answer" : {         "name" : "Less than $20,000",         "id" : "q343.551",         "value" : "false"       }     }, {       "answer" : {         "name" : "$20,000–$49,999",         "id" : "q343.552",         "value" : "false"       }     }, {       "answer" : {         "name" : "$50,000–$74,999",         "id" : "q343.553",         "value" : "false"       }     }, {       "answer" : {         "name" : "$75,000–$99,999",         "id" : "q343.554",         "value" : "true"       }     }, {       "answer" : {         "name" : "$100,000–$499,999",         "id" : "q343.555",         "value" : "false"       }     }, {       "answer" : {         "name" : "$500,000 or more",         "id" : "q343.556",         "value" : "false"       }     }, {       "answer" : {         "name" : "Less than $20,000",         "id" : "q344.557",         "value" : "true"       }     }, {       "answer" : {         "name" : "$20,000–$49,999",         "id" : "q344.558",         "value" : "false"       }     }, {       "answer" : {         "name" : "$50,000–$74,999",         "id" : "q344.559",         "value" : "false"       }     }, {       "answer" : {         "name" : "$75,000–$99,999",         "id" : "q344.560",         "value" : "false"       }     }, {       "answer" : {         "name" : "$100,000–$499,999",         "id" : "q344.561",         "value" : "false"       }     }, {       "answer" : {         "name" : "$500,000 or more",         "id" : "q344.562",         "value" : "false"       }     }, {       "answer" : {         "name" : "Less than $20,000",         "id" : "q345.563",         "value" : "false"       }     }, {       "answer" : {         "name" : "$20,000–$49,999",         "id" : "q345.564",         "value" : "false"       }     }, {       "answer" : {         "name" : "$50,000–$74,999",         "id" : "q345.565",         "value" : "false"       }     }, {       "answer" : {         "name" : "$75,000–$99,999",         "id" : "q345.566",         "value" : "true"       }     }, {       "answer" : {         "name" : "$100,000–$499,999",         "id" : "q345.567",         "value" : "false"       }     }, {       "answer" : {         "name" : "$500,000 or more",         "id" : "q345.568",         "value" : "false"       }     }, {       "answer" : {         "name" : "WRI_0000_sourceSystem",         "id" : "q500.831",         "value" : "DOI"       }     }, {       "answer" : {         "name" : "WRI_0000_appId",         "id" : "q501.832",         "value" : "MEL"       }     }, {       "answer" : {         "name" : "WRI_V793_INFLID",         "id" : "q505.893",         "value" : "INFL069070844367"       }     }, {       "answer" : {         "name" : "WRI_V793_clientId",         "id" : "q507.895",         "value" : "2005148508"       }     }, {       "answer" : {         "name" : "WRI_V793_clientSegmentCode",         "id" : "q509.897",         "value" : "Voyager Select"       }     }, {       "answer" : {         "name" : "WRI_V793_accountNumber",         "id" : "q510.898",         "value" : "84344977"       }     } ],     "username" : "Guest",     "completionTimeUTC" : "2019-08-07T12:45:41.2390287",     "completed" : "true",     "workflowInProgress" : "false",     "runId" : "93957291-b1dc-4347-92b3-6f110e99b475"   } ] }"

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi ,

    JSON you shared seems to be invalid as it starts with "{ instead of just { and also ends with }" instead of }

    Possible solutions:

    1. Before writing to the database, ensure the data from external sources is converted to Valid Json using a!toison() function.

    2. If you want the existing one to work, you can use the below expression. This is a workaround which handles the input you have shared and might work unexpectedly for other input data.

    a!fromjson(
      substitute(
        substitute(
          ri!a,
          """{",
          "{"
        ),
        "}""",
        "}"
      )
    )

Reply
  • 0
    Certified Lead Developer

    Hi ,

    JSON you shared seems to be invalid as it starts with "{ instead of just { and also ends with }" instead of }

    Possible solutions:

    1. Before writing to the database, ensure the data from external sources is converted to Valid Json using a!toison() function.

    2. If you want the existing one to work, you can use the below expression. This is a workaround which handles the input you have shared and might work unexpectedly for other input data.

    a!fromjson(
      substitute(
        substitute(
          ri!a,
          """{",
          "{"
        ),
        "}""",
        "}"
      )
    )

Children
No Data