Hi All,
I want to get “id”,price and category from json - dummyjson.com/products and stored it into datatable.
i am able to fetch data using http request and converted into Jobject using deserialization. dataTable is created.
I am stuck in For loop can anyone help
the output of deserialize json is like key value pairs
item(“products”)(“id”).tostring gives you only one value
if you want to add it to datatable
use deserialize json array activity and use add datarow activity and pass the output of the deserialize json array to it
Hi @TUSHAR_DIWASE
Could you try the following expressions inside the For Each activity?
id = item.SelectToken("id").ToObject(Of Integer)()
price = item.SelectToken("price").ToObject(Of Double)()
category = item.SelectToken("category").ToString()
Hope this helps,
Best Regards.
tried but got below error
sorry @sasi_poosarla i am new to it so can you please help me more in deep. ro share in sample wf for the same
@TUSHAR_DIWASE
Could you try closing the studio, restart the program & running this workflow again?
Best Regards.
ppr
(Peter Preuss)
7
we deserialized the JSON - output: myJObject
A quick approach would be to convert all into a datatable
and then remove the unneeded columns (removal can be done with several approaches)
Assign Activity:
dtData =
myJObject("products").ToObject(Of DataTable).DefaultView.ToTable(false,new String(){"id","price","category"})
when looping and collecting the values one by one we use the Value method for the retrieval
ppr
(Peter Preuss)
8
we could do:
TypeArgument: JObject
retrieval as:
item("id").Value(Of Int32)
item("price").Value(Of Double)
item("category").Value(Of String)