Problem json deserialize activity

Hello everybody.
I’m stuck with the json deserialize.
I receive this json from previous python call.
“{"9422D9F2-0F4E-414D-9534-0948A8 - Copia.jpg": {"location": "C:\python_test\buttare\/9422D9F2-0F4E-414D-9534-0948A8 - Copia.jpg", "duplicates": ["C:\python_test\buttare\/9422D9F2-0F4E-414D-9534-0948A8.jpg"]}}”

I want to extract the item: “location” and “duplicates”.

How can i do?
Note the name file “9422D9F2-0F4E-414D-9534-0948A8 - Copia.jpg” change everytime!!

thanks a lot
Loris

Hi @loriss84robot ,

Could you place the json text received from Python call inside the preformatted text like below :

This is inside Preformatted text

In this way, we make sure that no formats are altered.

"{\"9422D9F2-0F4E-414D-9534-0948A8 - Copia.jpg\": {\"location\": \"C:\\python_test\\buttare\\/9422D9F2-0F4E-414D-9534-0948A8 - Copia.jpg\", \"duplicates\": [\"C:\\python_test\\buttare\\/9422D9F2-0F4E-414D-9534-0948A8.jpg\"]}}"

and the variable after json deserialize is

JObject(1) { JProperty(1) { JObject(2) { JProperty(1) { [C:\python_test\buttare\/9422D9F2-0F4E-414D-9534-0948A8 - Copia.jpg] }, JProperty(1) { JArray(1) { [C:\python_test\buttare\/9422D9F2-0F4E-414D-9534-0948A8.jpg] } } } } }

thanks!

Hija,

deserialize as:
jsonObj=
Newtonsoft.Json.JsonConvert.DeserializeObject(Of Dictionary(Of String, Dictionary(Of String, Object) ))(input)

Then get value dictVal=Newtonsoft.Json.JsonConvert.DeserializeObject(Of Dictionary(Of String, Object))(Newtonsoft.Json.JsonConvert.SerializeObject( jsonObj.Values.First))

you can then get location by dictVal(“location”).ToString

thanks for your reply.
Sorry but i don’t understand it.
You wrote deserialize as:

That mean i don’t use deserialize json activity but i need to use assign activity?
the variable type is?

dictval what is the variable type?

thanks

you can still use the Deserialize JSON activity . Just change the TypeArgument to Dictionary(Of String, Dictionary(Of String, Object)

dictval is the Dictionary(Of String, Object) : if you are sure all values are strings you can also make it Dictionary(Of String, String) ofcourse.