I am trying to add JSON object inside a JSON object but the generated JSON is not in the correct format. The child json is in double quotes.
How can I get rid of these double quotes? Can someone help me with a correct substitute() function command?
Discussion posts and replies are publicly visible
Are you trying to generate it via Appian expressions?
Hey Harshit, I am working under expression mode and below is what I wrote to achieve
local!dataPerfect:a!toJson( {"testifact_info":a!toJson( {"testsuite_name":local!testSuiteName, "testsuite_owner":local!testSuiteOwner, "testsuite_description":local!testSuiteDescription, "test_report_path":local!testReportPath, "variable_map_external": local!variableMapPath, "object_map_external":local!objectMapPath }) } ),
and then I am printing the dataPerfect variable in a richtext block
For me, it is generating a valid JSON. You can try validating your JSON here - jsonformatter.curiousconcept.com/
Thanks Harshit! I figured out another way
puneetk0004 can you please share how did you fixed it? I am facing same issue.
it's not a valid JSON from logical point of view. Because of the highlighted double quotes the entire child objects are considered as a string value, which is not correct.
If stripwith() or substitute() like functions are used to remove characters from the json structure, then it returns the resulting json wrapped by double quotes like the one in your query, because these functions returns text. If you are dealing with the multilevel nested JSON then it becomes difficult.
@Abhay - For the JSON screenshot shared in my question above, i tried this:
local!a: a!map( testifact_info: { testsuite_name: local!testSuiteName, testsuite_owner: local!testSuiteOwner,})
local!testData: a!toJson( value: local!a, removeNullOrEmptyFields: true ),
this way I got rid of double quotes