How can I fetch the values using key from JsonObject?

Hello Team,

I want only 4 values from the below nested jsonObject :slight_smile:

  • number = “OTC0001693”
  • case = “Serbia OTC Delivery Billing Automation Dummy​OTC0001693”
  • state = “1”
  • sys_id = 0169e81ac3d05618f7bf206dc00131c4

Please help experts: @Anil_G , @lrtetala , @Botzilla

Please find the below Json object for your reference:

{
“result”: [
{
“parent”: “”,
“related_party_consumers”: “”,
“case_action_summary”: “”,
“caused_by”: “”,
“watch_list”: “”,
“related_party_users”: “”,
“u_from_mailbox”: “”,
“active_escalation”: “”,
“upon_reject”: “cancel”,
“sys_updated_on”: “2024-09-03 07:08:48”,
“support_manager”: “”,
“approval_history”: “”,
“skills”: “”,
“number”: “OTC0001693”,
“problem”: “”,
“state”: “1”,
“u_delivery_number”: “”,
“u_po_number”: “”,
“case”: “Serbia OTC Delivery Billing Automation Dummy​OTC0001693”,
“knowledge”: “false”,
“order”: “”,
“assigned_on”: “”,
“cmdb_ci”: “”,
“delivery_plan”: “”,
“contract”: “”,
“impact”: “3”,
“u_business_poc”: “”,
“active”: “true”,
“work_notes_list”: “”,
“u_language”: “”,
“priority”: “4”,
“sys_domain_path”: “/”,
“business_duration”: “”,
“first_response_time”: “”,
“group_list”: “”,
“u_alternative_poc_selection”: “false”,
“u_sales_org”: “”,
“sync_driver”: “false”,
“u_alternative_poc”: “”,
“approval_set”: “”,
“u_cost_center”: “”,
“needs_attention”: “false”,
“universal_request”: “”,
“short_description”: “Serbia OTC Delivery Billing Automation Dummy”,
“correlation_display”: “”,
“work_start”: “”,
“u_approver_user”: “”,
“additional_assignee_list”: “”,
“u_child_case_table”: “”,
“notify”: “1”,
“service_offering”: “”,
“closed_by”: “”,
“follow_up”: “”,
“sold_product”: “”,
“post_case_review”: “”,
“contact_local_time”: “”,
“sn_app_cs_social_social_profile”: “”,
“u_fulfiller_name”: “”,
“reassignment_count”: “0”,
“contact_time_zone”: “”,
“contributor_users”: “”,
“notes_to_comments”: “false”,
“assigned_to”: “”,
“product”: “”,
“sla_due”: “”,
“change”: “”,
“comments_and_work_notes”: “”,
“u_amount”: “”,
“partner”: “”,
“escalation”: “0”,
“upon_approval”: “proceed”,
“partner_contact”: “”,
“correlation_id”: “”,
“asset”: “”,
“u_material_id”: “”,
“u_assignment_group_change”: “2024-08-30 13:48:42”,
“made_sla”: “true”,
“u_division”: “”,
“u_billing_number”: “”,
“u_erp_vendor_number”: “”,
“task_effective_number”: “OTC0001693”,
“resolved_by”: “”,
“sys_updated_by”: “jinc”,
“u_plant”: “”,
“user_input”: “”,
“sys_created_on”: “2024-08-30 13:48:42”,
“contact”: “”,
“route_reason”: “”,
“u_erp_vendor_name”: “”,
“contributor_groups”: “”,
“u_reopen”: “false”,
“closed_at”: “”,
“follow_the_sun”: “false”,
“business_service”: “”,
“entitlement”: “”,
“u_poc_generic_email”: “”,
“time_worked”: “”,
“expected_start”: “”,
“opened_at”: “2024-08-30 13:41:41”,
“work_end”: “”,
“consumer_profile”: “”,
“resolved_at”: “”,
“u_invoice_currency”: “”,
“subcategory”: “96”,
“work_notes”: “”,
“install_base”: “”,
“sentiment”: “”,
“u_company_code”: “”,
“cause”: “”,
“description”: “”,
“proactive”: “false”,
“calendar_duration”: “”,
“close_notes”: “”,
“auto_close”: “false”,
“sys_id”: “0169e81ac3d05618f7bf206dc00131c4”,
“contact_type”: “web”,
“resolution_code”: “”,
“urgency”: “3”,
“u_state_chanfe”: “2024-08-30 13:48:42”,
“company”: “”,
“activity_due”: “”,
“consumer”: “”,
“action_status”: “”,
“comments”: “”,
“approval”: “not requested”,
“due_date”: “”,
“sys_mod_count”: “4”,
“sys_tags”: “”,
“u_poc_approval_status”: “”,
“prediction_status”: “3”,
“active_account_escalation”: “”,
“category”: “81”,
“account”: “”
}
]
}

@hacky

use deserialize json and pass this string and get output jobject say jobj

then jobj("result")(0)("number").ToString will give number similarly get remaining as well

cheers

Hi @hacky

number = jsonObject(“result”)(0)(“number”).ToString()
case = jsonObject(“result”)(0)(“case”).ToString()
state = jsonObject(“result”)(0)(“state”).ToString()
sys_id = jsonObject(“result”)(0)(“sys_id”).ToString()

Regards,

Hi,

Use “Deserialize JSON”, this will return a JSON Object

image

This image depicts the properties panel for the "Deserialize JSON" activity in UiPath, showing the input and output fields for handling JSON data. (Captioned by AI)

Then you could extract them like this

// extract "result" from JResponse as a JSON Array
myFeatures = New JArray(JResponse("result").ToArray())

// extract the value as a String by passing the key name
number = myFeatures("number").Value(Of String)

feel free to also play array with the Newtonsoft.JSON class, you might find more interesting solutions.

Activities - Deserialize JSON (uipath.com)

Serializing and Deserializing JSON (newtonsoft.com)