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.