You are viewing limited content. For full access, please sign in.

Question

Question

Feature Request: Automatically convert a JSON array into a multivalue token

asked on May 21, 2016 Show version history

I'm processing the following with the Read JSON activity:

{"books":["book1","book2"]}

Even though I have the "all matches (as a multi-value token)" option selected, the $.books XPath expression results in the following (copied from the WF results window):

[
  "book1",
  "book2"
]

I feel like it should result in a multivalue token containing book1 and book2 instead. (I've read the Goessner spec and I understand why it works the way it does - it's just not very user-friendly when dealing with array data. I think Workflow should do some post-processing on the output of the JSONPath library.)

I've resorted to using the following script to remove the brackets, new lines, spaces and quotes:

string currentValue = GetTokenValue("ReadJSON_Books").ToString();
var charsToRemove = new String[] {"[", "]", "\"", "\n", "\r", " "};
foreach (var c in charsToRemove) {
         currentValue = currentValue.Replace(c, String.Empty);
}
SetTokenValue("Cleaned Up Value", currentValue);

I then use the Split function in the Token Editor to convert the value (which is now book1,book2) into a multivalue token.

0 0

Replies

replied on May 24, 2016

Try this path: $.books[*] from http://goessner.net/articles/JsonPath/ 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.