I need to be able to extract the key: “Number” and corresponding value: “RITM0041763” from this array. This particular file has a plethora of these key/value pairs from the document. I have traditionally deserialized JSON files I created manually using the Deserialize JSON activity and then used 'JSON(“Number”) but due to the nested nature of this file, it will not work.
Uploaded below - if you have a solution in mind which is easy to change (ex. the key values are different) that would be largely helpful as I need to reconfigure this for multiple use cases.
I just started looking into it. Do you mind sharing how did you setup the Form Recognizer? I had found and installed a “Microsoft.Azure.CognitiveServices.FormRecognizer” package, but can’t figure out how to use it.
I had someone from Microsoft help me parse the key/value pairs however it is in Python, not VB.NET so I cannot translate it to UiPath well. Can someone take a look and see what they can do? See below:
import json
response_file = “response.json”
Specify the list of keys to be reported.
keys = set([“Address:”])
with open(response_file, mode = “r”, encoding = “utf-8”) as f:
data = json.load(f)
# Loop over all pages in the document.
for page in data[“pages”]:
# Loop over all key/value pairs in the page.
for kvp in page[“keyValuePairs”]: key_txt = " ".join([x[“text”] for x in kvp[“key”]])
# Report only the pre-specified subset of keys.
if key_txt in keys:
print(“key: %s” % key_txt)
vals = [x[“text”] for x in kvp[“value”]]
print(“value: %s” % " ".join(vals))
I tried building a nested for-each loop but the bolded line I included is not translating into VB within UiPath.
Sorry, the code has all my credentials and some confidential data.
But no worries, as you are constructing a string in the print statement, just change it as return statement and capture it as the string in uipath workflow, but here is the code for your reference. Sure you will understand this
Worked like a charm! Had to make some tweaks to my .PY file that Microsoft provided (converted it to a function) so that I could pull data out of it back to the workflow. Other than that - THANKS!