Read JSON from Email Body (IMAP)

Hi everyone,

I am trying to read the body of an email containing a JSON. When I disable activities I was able to figure out the error is being thrown in my Deserialize JSON array activity.

Here is the error I am getting: Deserialize JSON Array: Unexpected character encountered while parsing value: <. Path ‘’, line 0, position 0.

Please help!

Thanks,
Emily

you will need to remove this

<pre> and </pre>

from the body first…

1 Like

Hi @eonofrey,

Try removing the “<pre>” and “</pre>” before deserialization.

Cheers

Hi @eonofrey,

Try removing < pre> and < /pre> a JSON have to start with “{” and ends with “}” and JSON ARRAY have to start with “[” and ends with “]”. So, in your particular case (because you are using Deserialize JSON Array activity) you shoud replace
< pre> by [ and < /pre> by ]
I hope it helps you

Thank you all. I made some updates to the email format. I am not able to split the email body to

emailBodyTrim(0) --> which is the JSON (attached in message box screenshot)
emailBodyTrim(1) --> my email signature

Here is the error I am getting now: Deserialize JSON Array: Error reading JArray from JsonReader. Current JsonReader item is not an array: StartObject. Path ‘’, line 1, position 1.

Again, my goal is to parse through the JSON to get each data value.

json

change activity deserialize array to the normal one…

That worked but now I have a new issue.

Do I need to change the Type Argument?

you should remove the for each i guess, unless you want to print every value in that json…

I need to assign each individual value to a variable.

I am trying to figure out a string conversion because this is the error I am getting: Message Box: Cannot access child value on Newtonsoft.Json.Linq.JProperty.

YourJsonVariable(“tenant”)(“firstname”) and so on…

I am still getting the error: Message Box: Object reference not set to an instance of an object.

Go into debug mode and see what you have in your jsonobject after deserialize.

I meant use this one, opening the object in Locals:
image

Here is the JsonObject expanded from debug mode…

Your object seems ok, the keys are case sensitive tho… YourJsonVariable(“tenant”)(“firstName”) should work

Good point, however I still have the same error. Any other ideas?

firstName is in tentant so you need to access that first…
MyFirstName = parseMsg(“tenant”)(“firstName”)
MyLastName = parseMsg(“tenant”)(“lastName”)

1 Like

Assign Activity
fn = parseMsg(“tenant”)(“firstName”).ToString

Worked for me… thank you for all your help!

1 Like

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