How can we convert a text to JSON in uipath

Can anyone help on suggesting How can we convert a text to JSON in uipath?

please share some sample data along with expected JSON result with us. Thanks

I have a pdf from which I have to extract data using OCR . The result should be converted to JSON.


Hey @db64a40e754add3bd2df0ad39 ! You can use “Deserialize Json” Activity to do that!

The Output need to be a “JObject” variable!
The input is you String in the correct pattern for a Json.

I dont have samples to go deep into an explanation, but let us know if it works for you!

Get This package to use this activity.

i am getting the above error if i follow the steps

Hi @db64a40e754add3bd2df0ad39,

Before you use Deserialize Json as @gabrielribas4 suggested, you will have to ensure your extracted text from the OCR is processed further.

Deserialize Json activity looks strictly for Json syntax in the string. The error you are getting means that the OCR activity probably only extracted certain characters and escaped important ones. For example, your OCR result might have missed double quotes for a key in Json, which the Deserialize Json cannot parse.

  1. Values from OCR
  2. Instead of passing the values, check if your extracted string satisfies json syntax.
  3. If it satisfies then use Deserialize Json (this way you avoid getting the unexpected character error)

If you are extracting many values from OCR may be perform some string manipulation / regex to build up a Dictionary with key and values so that you can convert the dictionary to a json object later. This is the cleanest way to achieve what you are looking for, but also the most time consuming.

1 Like

Perfect!!! @jeevith

Thank you

Hey @db64a40e754add3bd2df0ad39, can you mark as Solved and close the topic? Thank you!!