Deserialize json array not Working

Hello Everywone,
ApiExtract.xaml (6.3 KB)
my json file below, when I try to deserialize it to an array I receive the error :
Deserialize json array : Error reading JArray from JsonReader. Current JsonReader item is not an array: StartObject. Path ‘’, line 1, position 1.

can you help me?

we cannot see your JSON. Please use the format button </> from the editor or upload the json file (Maybe you rename the extension to txt)

{“success”:true,“data”:[{“snfId”:10136,“codCfop”:“5949/AA”,“centroLog”:“OF03”,“idUsuarioInclusao”:“KSAT”,“idUsuarioAlteracao”:null,“numNf”:null,“comentario”:“Devolução de Casco Reman - conforme fornecimento OV: 3294032, PO: 4501070994 - NF: 380419 - Cormoran DG3 e DG4”,“codcentroLog”:“OF”,“tpoentsai”:“S”,“razaosocial”:“WILSON SONS OFFSHORE SA”,“endereco”:“RUA BRASIL”,“numend”:“25”,“complend”:null,“bairro”:“PONTA D’ AREIA”,“cidade”:“NITEROI”,“uf”:“RJ”,“cep”:“24040-260”,“cnpj”:“08.376.900/0003-01”,“cnpjCompl”:“0003-01”,“razaoSocialFornec”:“SOTREQ S/A”,“endFornec”:“AVENIDA BRASIL”,“numEndFornec”:“7200”,“complEndFornec”:null,“bairroFornec”:“BONSUCESSO”,“cidadeFornec”:“RIO DE JANEIRO”,“ufFornec”:“RJ”,“cepFornec”:“21030-001”,“cnpjFornec”:“34.151.100/0003-00”,“ieFornec”:“79136700”,“naturezaOperacao”:“5949”,“chaveNfae”:null,“situacaoNfae”:null,“emailUsuarioInclusao”:“kleber.sabino@wsut.com.br”}]}{“success”:true,“data”:[{“snfId”:10136,“codCfop”:“5949/AA”,“centroLog”:“OF03”,“idUsuarioInclusao”:“KSAT”,“idUsuarioAlteracao”:null,“numNf”:null,“comentario”:“Devolução de Casco Reman - conforme fornecimento OV: 3294032, PO: 4501070994 - NF: 380419 - Cormoran DG3 e DG4”,“codcentroLog”:“OF”,“tpoentsai”:“S”,“razaosocial”:“WILSON SONS OFFSHORE SA”,“endereco”:“RUA BRASIL”,“numend”:“25”,“complend”:null,“bairro”:“PONTA D’ AREIA”,“cidade”:“NITEROI”,“uf”:“RJ”,“cep”:“24040-260”,“cnpj”:“08.376.900/0003-01”,“cnpjCompl”:“0003-01”,“razaoSocialFornec”:“SOTREQ S/A”,“endFornec”:“AVENIDA BRASIL”,“numEndFornec”:“7200”,“complEndFornec”:null,“bairroFornec”:“BONSUCESSO”,“cidadeFornec”:“RIO DE JANEIRO”,“ufFornec”:“RJ”,“cepFornec”:“21030-001”,“cnpjFornec”:“34.151.100/0003-00”,“ieFornec”:“79136700”,“naturezaOperacao”:“5949”,“chaveNfae”:null,“situacaoNfae”:null,“emailUsuarioInclusao”:“kleber.sabino@wsut.com.br”}]}

It’s true, it is not an array :slight_smile:
It does contain arrays as sub-nodes though.

Deserialise it with the regular deserialize JSON activity and use a jsonobject as output instead of jsonarray.


myJObject("data").Value(Of JArray)
myJObject("data")(0).Value(of JObject)

Hello my friend, what did you do to be able to display this output??

in general it was done like this:
grafik

for working with the immediate panel have a look here:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Mine is giving this error:

[image]

Deserialize JSON: Cannot create and populate list type Newtonsoft.Json.Linq.JToken. Path ‘data’, line 1, position 24.

follow the txt

[image]
{“success”:true,“data”:[{“snfId”:10219,“codCfop”:“5915/AA”,“centroLog”:“OF03”,“idUsuarioInclusao”:“T_MWFS”,“idUsuarioAlteracao”:null,“numNf”:null,“comentario”:“luiz Nery / Sterna”,“codcentroLog”:“OF”,“tpoentsai”:“S”,“razaosocial”:“WILSON SONS OFFSHORE SA”,“endereco”:“RUA PIRANGI”,“numend”:“25”,“complend”:null,“bairro”:“PONTA D’ AREIA”,“cidade”:“NITEROI”,“uf”:“RJ”,“cep”:“24040-260”,“cnpj”:“08.376.900/0003-01”,“cnpjCompl”:“0003-01”,“razaoSocialFornec”:“PRISMAR INDUSTRIA E COMERCIO DETROCADORES DE CALOR”,“endFornec”:“RUA PIRANGI”,“numEndFornec”:“128”,“complEndFornec”:null,“bairroFornec”:“OLARIA”,“cidadeFornec”:“RIO DE JANEIRO”,“ufFornec”:“RJ”,“cepFornec”:“21021-550”,“cnpjFornec”:“30.706.592/0001-22”,“ieFornec”:“87306054”,“naturezaOperacao”:“5915”,“chaveNfae”:null,“situacaoNfae”:null,“emailUsuarioInclusao”:“mariacarolina.silva@wsut.com.br”}]}

use JSON Lint https://jsonlint.com/
and get the JSON corrected till it will be valid

Peter, thank you very much, I managed to solve the problem, it was the package that was out of date, now during the for each it is showing this problem

For Each - SNFs: Unable to cast object of type ‘Newtonsoft.Json.Linq.JProperty’ to type ‘Newtonsoft.Json.Linq.JObject’.

And I configured the object type in for each correctly

can you show us what is used within the for each for the loop?

follow json:
Untitled.txt (850 Bytes)

image