gokul1904
(Glory 01)
September 23, 2022, 8:29am
1
Hi team ,
This is my json -
[{“WD_ExceptionID”:“WD-0003”,“WD_ExceptionMessage”:“Company Address is not matching with workday custom report”},{“WD_ExceptionID”:“WD-0003”,“WD_ExceptionMessage”:“Supplier Address is not matching with workday custom report”}]
I just want to obtain all the “WD_ExceptionMessage” in different lines.
How to achieve this after deserializing?
Regards,
G
ppr
(Peter Preuss)
September 23, 2022, 8:40am
2
we deserialize to a JArray:
can loop over it by:
or using LINQ:
arrExtractResult =
yourJArrayVar.SelectTokens("$..WD_ExceptionMessage").Select(Function (x) x.Value(Of String)).ToArray
bringing this array to flatten string with Linebreaks we can do:
String.Join(Environment.NewLine, arrExtractResult)
1 Like
Hello @gokul1904
You need to use like
item.SelectToken(“WD_ExceptionMessage”) inside the for each
Regards
Sudharsan
ppr
(Peter Preuss)
September 23, 2022, 8:43am
4
Kindly note: we do have two methods
SelectTokens <-s - retrieval all founds
And SelectToken ← without s - retrieve first found
Hi @gokul1904 ,
Could also try with an Alternate, direct convert to Datatable :
DT = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Datatable)(strJson)
Here, strJson
is the Json data (JArray) that you have in string format.
1 Like
system
(system)
Closed
September 26, 2022, 8:44am
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.