<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic RE: Web Service JSON Path parsing in Digital Exchange</title>
    <link>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58198#M1602</link>
    <description>Based on the example JSON you provided in the other thread here's some code that parses the array.&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt;JArray topArray = JArray.Parse(json);
JArray issues = (JArray)array.SelectToken(query);

foreach (JObject issue in issues)
  {
    string id = (string)issue["id"];
    string expand = (string)issue["expand"];
    string self = (string)issue["self"];
    string key = (string)issue["key"];

    // Do something with the values (ex. populate a DataTable and return to process as Collection.

}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Keep in mind, this is loading an array at the beginning. If you full JSON is actually an object you'd need to do a JObject.Parse() to load it and then use SelectToken() to pull out the issues array.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Eric Wilson&lt;BR /&gt;Director, Partner Integrations for Digital Exchange&lt;BR /&gt;Blue Prism&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
    <pubDate>Mon, 12 Jul 2021 13:14:00 GMT</pubDate>
    <dc:creator>ewilson</dc:creator>
    <dc:date>2021-07-12T13:14:00Z</dc:date>
    <item>
      <title>Web Service JSON Path parsing</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58195#M1599</link>
      <description>Hello Everyone,&lt;BR /&gt;&lt;BR /&gt;I'm struggling recently with an error generated by Web Service action that has following Json Path applied as output parameter: &lt;STRONG&gt;$..issues&lt;/STRONG&gt;&lt;LI&gt;&lt;STRONG&gt;.key&lt;BR /&gt;&lt;/STRONG&gt;&lt;BR /&gt;The error thrown at the process layer is: &lt;STRONG&gt;ERROR: Internal : Unexpected error Path returned multiple tokens.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;The problem is that I indeed want to receive multiple tokens as an output, however, I have no idea how to put this in a collection or text variable...&lt;BR /&gt;&lt;BR /&gt;I will be grateful for any help.&lt;BR /&gt;&lt;BR /&gt;Thanks and Best Regards,&lt;BR /&gt;Mateusz&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Mateusz Bartczak&lt;BR /&gt;------------------------------&lt;BR /&gt;&lt;/LI&gt;</description>
      <pubDate>Thu, 08 Jul 2021 07:59:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58195#M1599</guid>
      <dc:creator>MateuszBartczak</dc:creator>
      <dc:date>2021-07-08T07:59:00Z</dc:date>
    </item>
    <item>
      <title>RE: Web Service JSON Path parsing</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58196#M1600</link>
      <description>Hi, Mateusz,&lt;BR /&gt;&lt;BR /&gt;I am afraid that you need to write your own function for that. Blue Prism Web API does not support (or has not supported yet) the multiple tokens. It is a pity and I raised an enhancement request some time ago (https://community.blueprism.com/innovate/ideas/viewidea?IdeationKey=fb08bdac-8f18-4ac8-95e8-0a2e668393c8) so if you want to help pushing it into the main product please vote for it. That's all what I can advice at this moment.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Zdenek&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Zdeněk Kabátek&lt;BR /&gt;Head of Professional Services&lt;BR /&gt;NEOOPS&lt;BR /&gt;&lt;A href="http://www.neoops.com/" target="test_blank"&gt;http://www.neoops.com/&lt;/A&gt;&lt;BR /&gt;Europe/Prague&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Sun, 11 Jul 2021 18:05:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58196#M1600</guid>
      <dc:creator>zdenek.kabatek</dc:creator>
      <dc:date>2021-07-11T18:05:00Z</dc:date>
    </item>
    <item>
      <title>RE: Web Service JSON Path parsing</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58197#M1601</link>
      <description>Hi Zdenek,&lt;BR /&gt;&lt;BR /&gt;Thank you for answer. Do you have any sample of working code for that? I was trying to use Newtosoft for that and tried something like:&lt;BR /&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt;JObject o = JObject.Parse(Response_Content);
JToken i = o.SelectToken("$..issues&lt;/CODE&gt;&lt;LI&gt;&lt;CODE&gt;.key");​&lt;/CODE&gt;&lt;/LI&gt;&lt;/PRE&gt;
&amp;nbsp;&lt;BR /&gt;and then split the token or use foreach to put it in a datatable but unfortunetely it's not working too (still the same error of multiple tokens)&lt;BR /&gt;&lt;BR /&gt;Thanks &amp;amp; best regards&lt;BR /&gt;&lt;BR /&gt;Mateusz&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Mateusz Bartczak&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jul 2021 07:15:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58197#M1601</guid>
      <dc:creator>MateuszBartczak</dc:creator>
      <dc:date>2021-07-12T07:15:00Z</dc:date>
    </item>
    <item>
      <title>RE: Web Service JSON Path parsing</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58198#M1602</link>
      <description>Based on the example JSON you provided in the other thread here's some code that parses the array.&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt;JArray topArray = JArray.Parse(json);
JArray issues = (JArray)array.SelectToken(query);

foreach (JObject issue in issues)
  {
    string id = (string)issue["id"];
    string expand = (string)issue["expand"];
    string self = (string)issue["self"];
    string key = (string)issue["key"];

    // Do something with the values (ex. populate a DataTable and return to process as Collection.

}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Keep in mind, this is loading an array at the beginning. If you full JSON is actually an object you'd need to do a JObject.Parse() to load it and then use SelectToken() to pull out the issues array.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Eric Wilson&lt;BR /&gt;Director, Partner Integrations for Digital Exchange&lt;BR /&gt;Blue Prism&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jul 2021 13:14:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58198#M1602</guid>
      <dc:creator>ewilson</dc:creator>
      <dc:date>2021-07-12T13:14:00Z</dc:date>
    </item>
    <item>
      <title>RE: Web Service JSON Path parsing</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58199#M1603</link>
      <description>&lt;P&gt;Hi Mateusz,&lt;/P&gt;
&lt;P&gt;From your Json path I assume each object inside issues array has key which you are trying to retrieve, right? you can try out following where inside foreach you can write what you want to do or just put it in Datatable to return a collection.&lt;/P&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt;IEnumerable&amp;lt;JToken&amp;gt; i = o.SelectTokens("$..issues&lt;/CODE&gt;&lt;LI&gt;&lt;CODE&gt;.key");
foreach(JToken j in i)
{
    Console.WriteLine(j.ToString());
}&lt;/CODE&gt;&lt;/LI&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Gopal Bhaire&lt;BR /&gt;Analyst&lt;BR /&gt;Accenture&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Jul 2021 13:17:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58199#M1603</guid>
      <dc:creator>GopalBhaire</dc:creator>
      <dc:date>2021-07-12T13:17:00Z</dc:date>
    </item>
    <item>
      <title>RE: Web Service JSON Path parsing</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58200#M1604</link>
      <description>Hi Eric,&lt;BR /&gt;&lt;BR /&gt;Unfortunately, I tried this method with JSON object as my Response_Content is an Object but code below is throwing same error as simple JSON Path:&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;&lt;EM&gt;Internal : Unexpected error Cannot execute action "Get Assigned Issues" due to an error when running custom code: Path returned multiple tokens.&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/EM&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt;JObject o = JObject.Parse(Response_Content);
JToken issues = o.SelectToken("$..issues&lt;/CODE&gt;&lt;LI&gt;&lt;CODE&gt;.key");

var dataTable = new DataTable();

dataTable.Columns.Add("id");
dataTable.Columns.Add("expand");
dataTable.Columns.Add("self");
dataTable.Columns.Add("key");

foreach (JObject issue in issues)
  {
	DataRow row = dataTable.NewRow();
    row["id"] = (string)issue["id"];
    row["expand"] = (string)issue["expand"];
    row["self"] = (string)issue["self"];
    row["key"] = (string)issue["key"];
	dataTable.Rows.Add(row);
}

Issues = dataTable;&lt;/CODE&gt;&lt;/LI&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Mateusz Bartczak&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Jul 2021 13:44:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58200#M1604</guid>
      <dc:creator>MateuszBartczak</dc:creator>
      <dc:date>2021-07-13T13:44:00Z</dc:date>
    </item>
    <item>
      <title>RE: Web Service JSON Path parsing</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58201#M1605</link>
      <description>Change you JSON Path query to this:&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;SPAN&gt;$..issues&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;That should return the issues array. Then the foreach should work.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Eric Wilson&lt;BR /&gt;Director, Partner Integrations for Digital Exchange&lt;BR /&gt;Blue Prism&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Jul 2021 14:05:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58201#M1605</guid>
      <dc:creator>ewilson</dc:creator>
      <dc:date>2021-07-13T14:05:00Z</dc:date>
    </item>
    <item>
      <title>RE: Web Service JSON Path parsing</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58202#M1606</link>
      <description>Hi Gopal,&lt;BR /&gt;&lt;BR /&gt;Quite funny because this piece of code actually worked although there is no huge change in relation to Eric code...:&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt;JObject o = JObject.Parse(Response_Content);
IEnumerable&amp;lt;JToken&amp;gt; i = o.SelectTokens("$..issues&lt;/CODE&gt;&lt;LI&gt;&lt;CODE&gt;.key");
var tempIssue = "";

foreach(JToken j in i)
{
    tempIssue = tempIssue +","+(j.ToString());
}

Issues = tempIssue;​&lt;/CODE&gt;&lt;/LI&gt;&lt;/PRE&gt;
&lt;P&gt;For the testing purposes I was able to return it to a string with separator &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks!!!&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Mateusz Bartczak&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Jul 2021 14:06:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58202#M1606</guid>
      <dc:creator>MateuszBartczak</dc:creator>
      <dc:date>2021-07-13T14:06:00Z</dc:date>
    </item>
    <item>
      <title>RE: Web Service JSON Path parsing</title>
      <link>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58203#M1607</link>
      <description>You are right, it worked too. Many thanks!&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Mateusz Bartczak&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Jul 2021 14:08:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Digital-Exchange/Web-Service-JSON-Path-parsing/m-p/58203#M1607</guid>
      <dc:creator>MateuszBartczak</dc:creator>
      <dc:date>2021-07-13T14:08:00Z</dc:date>
    </item>
  </channel>
</rss>

