-1

In Automation Anywhere, how to we parse a json string which is response to the REST API call? Unlike UiPath, AA does not seem to have a deserialize option for JSON String.

My aim here is to extract "item" details from the "searchResult" element. Please help.

Below is my json string:

[{"findItemsByKeywordsResponse":\[{"ack":\["Success"\],"version":\["1.13.0"\],"timestamp":\["2018-08-06T19:30:50.830Z"\],"searchResult":\[{"@count":"2","item":\[{"itemId":\["253482447437"\],"title":\["*Sealed in Box*  Verizon Apple iPhone SE 16/64GB 4.0\" Unlocked Smartphone"\],"globalId":\["EBAY-US"\],"subtitle":\["NO-RUSH 14 DAYS SHIPPING ONLY!  US LOCATION!"\],"primaryCategory":\[{"categoryId":\["9355"\],"categoryName":\["Cell Phones & Smartphones"\]}\],"galleryURL":\["http://thumbs2.ebaystatic.com/pict/253482447437404000000004_1.jpg"\],"viewItemURL":\["http://www.ebay.com/itm/Sealed-Box-Verizon-Apple-iPhone-SE-16-64GB-4-0-Unlocked-Smartphone-/253482447437?var=552665991559"\],"paymentMethod":\["PayPal"\],"autoPay":\["false"\],"postalCode":\["10002"\],"location":\["New York,NY,USA"\],"country":\["US"\],"shippingInfo":\[{"shippingServiceCost":\[{"@currencyId":"USD","__value__":"0.0"}\],"shippingType":\["Free"\],"shipToLocations":\["Worldwide"\],"expeditedShipping":\["false"\],"oneDayShippingAvailable":\["false"\],"handlingTime":\["3"\]}\],"sellingStatus":\[{"currentPrice":\[{"@currencyId":"USD","__value__":"260.99"}\],"convertedCurrentPrice":\[{"@currencyId":"USD","__value__":"260.99"}\],"sellingState":\["Active"\],"timeLeft":\["P1DT14H31M1S"\]}\],"listingInfo":\[{"bestOfferEnabled":\["false"\],"buyItNowAvailable":\["false"\],"startTime":\["2018-03-11T10:01:51.000Z"\],"endTime":\["2018-08-08T10:01:51.000Z"\],"listingType":\["StoreInventory"\],"gift":\["false"\],"watchCount":\["104"\]}\],"returnsAccepted":\["true"\],"condition":\[{"conditionId":\["1000"\],"conditionDisplayName":\["New"\]}\],"isMultiVariationListing":\["true"\],"topRatedListing":\["false"\]},{"itemId":\["401421457135"\],"title":\["Apple iPhone 7 \"Factory Unlocked\" 32GB 4G LTE iOS WiFi Smartphone"\],"globalId":\["EBAY-US"\],"subtitle":\["USA Seller - No Contract Required - Fast Shipping!!"\],"primaryCategory":\[{"categoryId":\["9355"\],"categoryName":\["Cell Phones & Smartphones"\]}\],"galleryURL":\["http://thumbs1.ebaystatic.com/pict/04040_0.jpg"\],"viewItemURL":\["http://www.ebay.com/itm/Apple-iPhone-7-Factory-Unlocked-32GB-4G-LTE-iOS-WiFi-Smartphone-/401421457135?var=0"\],"paymentMethod":\["PayPal"\],"autoPay":\["true"\],"postalCode":\["07014"\],"location":\["Clifton,NJ,USA"\],"country":\["US"\],"shippingInfo":\[{"shippingServiceCost":\[{"@currencyId":"USD","__value__":"0.0"}\],"shippingType":\["Free"\],"shipToLocations":\["Worldwide"\],"expeditedShipping":\["true"\],"oneDayShippingAvailable":\["false"\],"handlingTime":\["1"\]}\],"sellingStatus":\[{"currentPrice":\[{"@currencyId":"USD","__value__":"319.95"}\],"convertedCurrentPrice":\[{"@currencyId":"USD","__value__":"319.95"}\],"sellingState":\["Active"\],"timeLeft":\["P29DT23H2M23S"\]}\],"listingInfo":\[{"bestOfferEnabled":\["false"\],"buyItNowAvailable":\["false"\],"startTime":\["2017-10-10T18:33:13.000Z"\],"endTime":\["2018-09-05T18:33:13.000Z"\],"listingType":\["StoreInventory"\],"gift":\["false"\],"watchCount":\["9152"\]}\],"returnsAccepted":\["true"\],"condition":\[{"conditionId":\["2500"\],"conditionDisplayName":\["Seller refurbished"\]}\],"isMultiVariationListing":\["true"\],"topRatedListing":\["true"\]}\]}\],"paginationOutput":\[{"pageNumber":\["1"\],"entriesPerPage":\["6"\],"totalPages":\["2779640"\],"totalEntries":\["16677839"\]}\],"itemSearchURL":\["http://www.ebay.com/sch/i.html?_nkw=iPhone&_ddo=1&_ipg=6&_pgn=1"\]}\]}][1]
TylerH
  • 20,799
  • 66
  • 75
  • 101
BonnyGabriel
  • 11
  • 1
  • 2
  • You can't, it's why I write REST calls in C# or VBA and build a metabot. You can also use a `Find` to get the index, use `Before-After` to get the desired value and then `Substring` using the index+Length(value) to remove the already found value. Repeat until `Find` returns 0. – Roel Strolenberg Aug 10 '18 at 21:24

1 Answers1

0

Automation Anywhere does not come with a default JSON parsing tool. However, it does come with a DLL library you can use to translate JSON to XML, and AA works with XML documents just fine.

The library in question is Newtonsoft.Json.dll (you can find it in AA Client installation directory) and that has several useful methods for handling JSON (see here)

Marek Stejskal
  • 2,698
  • 1
  • 20
  • 30