JSON issue reading API

Afternoon All

Need some advice re extracting JSON data from a REST API call.

A partial extract of the data can be seen below

{
“calendar_integration”: “1”,
“country”: “”,
“last_position_update”: “”,
“user_password”: “”,
“last_login_time”: “2022-06-27 12:34:07”,
“sys_updated_on”: “2022-06-02 09:28:06”,
“building”: “”,
“u_last_refreshed”: “2016-09-10 23:00:00”,
“web_service_access_only”: “false”,
“notification”: “2”,
“managed_domain”: “false”,
“enable_multifactor_authn”: “false”,
“sys_updated_by”: “system”,
“agent_status”: “”,
“company”: {
“link”: “https://dev.org.com/api/now/table/core_company/720b00f86b74f449600a384c9310010c”,
“value”: “720b00f86b74f449600a384c9310010c”
},
“sys_created_on”: “2016-03-15 11:33:48”
}

I am fine with extracting the single value data -
eg userjsonResponse(“notification”).ToString should return 2

However I need to extract the value from the company - can anyone advise how to achieve this so I can assign the value 720b00f86b74f449600a384c9310010c to a variable.

Thanks

grafik
guess in your case:
userjsonResponse.("company")("value").value(of String)

EDIT: Postscriptum:
We recommend to check carefully when processing with regex (less recommended) to be free of any side effects like:

or a close dependency to formats

Hi @gary.cobden

You can also try with Regex Expression

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=value\D:\s\D).*(?=\D\n)").Tostring

Regards
Gokul

@gary.cobden
Try this regex Exp[ression

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=“value”:\s\W)[A-Za-z\S].+(?=\W\n)").Tostring.Trim```

No this is not the case
Turns out the most simplest way is o deserialise company

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.