Utility-JSON issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-01-18 09:56 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-01-18 06:12 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
24-03-20 11:31 AM
------------------------------
Cheers Astrid
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
25-03-20 10:54 AM
Dim objJSON As Object = JsonConvert.DeserializeObject(Of ExpandoObject)(strJSON)
For Each thing As Object In objJSON.Level1.Level2.things
'Do stuff here
Next
------------------------------
John Carter
Professional Services
Blue Prism
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
25-03-20 02:39 PM
Hi John,
many thanks for your reply.
While trying to prepare an example, I noticed that the "JSON to Collection (skipping JArray)" action seems to resolve this issue.
The only "problem" is now, that the "Collection to JSON" function adds a set of square brackets around the JSON string which the REST service I'm calling doesn't like. So I need to remove them using a calculation stage. But the rest seems to work fine then.
Thx,
Astrid
------Original Message------
Can you provide an example JSON Astrid? If a bespoke code solution is your best option, I've found using the ExpandoObject relatively painless:
Dim objJSON As Object = JsonConvert.DeserializeObject(Of ExpandoObject)(strJSON)
For Each thing As Object In objJSON.Level1.Level2.things
'Do stuff here
Next
------------------------------
John Carter
Professional Services
Blue Prism
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
06-04-20 02:39 PM
I was able to reproduce the issue now:
1. I'm using "JSON to Collection (skipping JArray)" with following JSON as Input and store the output in a collection "Coll":
{"filterCriterias":[{"attribute":"originator","filterType":"EQUALS","value":"1234567"}],"sortCriteria":{"sortType" : "DESC","sortBy": "id"}}
This returns a Collection containing 2 Collections, 1 row each.
2. Then I'm using "Collection to JSON" with the collection "Coll" as Input which returns:
[{"filterCriterias":[{"attribute":"originator","filterType":"EQUALS","value":"1234567"}],"sortCriteria":[{"sortType":"DESC","sortBy":"id"}]}]
So there are a few more square brackets in the resulting JSON string which my REST service doesn't accept.
I'd like to build a generic "search" action where users can pass the search criteria in one collection as input parameter.
I'd then transform this Collection to a JSON and use this for the REST service call, but as described above, the "Collection to JSON" doesn't return a JSON which my REST service accepts...
Any ideas?
------------------------------
Cheers Astrid
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
07-04-20 09:55 AM
a while ago I re-worked the complete Json Library. Maybe you can give it a try. see here: Using JSON VBO
------------------------------
Tobias Arnold
RPA Developer
ITERGO GmbH
Europe/Duesseldorf
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-04-20 09:52 AM
many thanks for your reply.
I actually found out that making my Input Collection a "Single Row" collection solves my problem with the surrounding square brackets which my REST service doesn't like.
I still tried your object quickly but it didn't convert the collection in the collection correctly. Instead of the parameter name it gave me "JSONArray"...
Thanks anyway!
------------------------------
Cheers Astrid
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
19-07-21 09:36 PM
Replace(Replace(Left(Right([Json Body], Len([Json Body])-1), Len([Json Body])-2), "[[{", "[{"), "}]]", "}]")
I hope it works!
Best wishes!
Federico
------------------------------
Federico Mignone
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
20-07-21 08:07 AM
I don't remember anymore actually how I solved it in the end, but I think it involved defining the result collection as "single row" (which requires to define the fields as well of course, so it's not super generic anymore but it worked for my process...).
------------------------------
Cheers Astrid
------------------------------
