hi… i have a workflow where i have to validate if my JSON Object variable has keys i want to find. i have the simper workflow screenshot below. could anyone help me with this?
1- Before performing the desensitization -> get the api response code ( like 200 ) then
I have imported ‘Json.Net’ package to the project
create a jObject variable like (responseJson)
parse and assign (responseJson) the the api response with parse (JObject.Parse(responseRequest))
you can use the responseJson object to retrive/validate the keys.
hi i don’t get it. i installed json.net package in the project but i can’t understand the next step i should do.
add ‘json.net’ package to your project.
create a variable - type is jObject (and variable name like responseJson)
parse and assign to (responseJson) the response using JObject.Parse
Before parsing can you check is the response is null or empty.
also pls log the response output and verify is that a valid json using online sites like (https://jsonformatter.curiousconcept.com/)
pls validate the json string in the provided site and verify. also please trim the response string in parsing
like - JObject.Parse(responseRequest.Trim)
can you able to share the output json -
please log the response using log message activity and copy the log data from output window, save it in text file and share it here
There is a simplest method to check that particular key exists or not you can do at string level. I mean text string you can do something like this
it will work too for sure.
test_result is of String Datatype
You can use Jtoken To check particular key exists or not and if exists then you can get value too.
To Check Key Exists or not -
test_output is of JObject Datatype
test_output.SelectTokens("Response.View.Result.Location.Address.State").Any() //Output - True
To Get Value of a Particular Key -
test_output.SelectToken("Response.View.Result.Location.Address.State").Value(of String) // Output - National Capital Region
Lemme know if you still have problems…!!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.