How to get text to json

Hi Team,

I want read txt and get dictionary value from txt file please help me anyone for this

{
“str_name”:“Arun”,
“str_deft”:“IT”,
“str_location”:“Chennai”
}

Input:
io_config(“str_Name”).ToString
io_config(“str_Deft”).ToString
io_config(“str_location”).ToString

Expected Output :
Arun
IT
Chennai

Regards,
Raja G

Hi @Raja.G ,

Maybe you could try the Following Steps :

  1. Read the text Data to a String variable using Read Text File Activity, output variable say dataText.

  2. Next, Use Deserialize Json Activity to get the output as a JObject variable, say jObj.

  3. Next, we could use the below Expression to directly convert to a Dictionary type value :

dictJson = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Dictionary(Of string,String))(jObj.tostring)

Here, dictJson is a variable of type Dictionary(Of String,String)

image

1 Like

@supermanPunch ,

Thank you , working fine

1 Like

Hi @supermanPunch ,

It is possible to use dictionary (string , object)?

I want to use string , object

@Raja.G ,

Just Change the Cast to Dictionary(Of String, Object) and check :

Newtonsoft.Json.JsonConvert.DeserializeObject(Of Dictionary(Of String,Object))(jObj.tostring)
1 Like

@supermanPunch Thank you

1 Like

Hi @supermanPunch ,

How to get regex value from json

“str_name”:“(?<=hello:)([\S\s]*)”

io_config(“str_name”).ToString

Please help me on this

@Raja.G ,

Since the Initial Requirement is resolved, for Issues considering a different topic, would request you to create a different Topic, so that we could provide individual help there and would avoid confusions for users who would also face the same issue as this Topic / Requirment States.

Hi @supermanPunch ,

Created new topic

Hi @supermanPunch ,

Please help me on this

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