<?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: Pass through JSON &amp;quot;string&amp;quot; from Database query in Workato Pros Discussion Board</title>
    <link>https://systematic.workato.com/t5/workato-pros-discussion-board/pass-through-json-quot-string-quot-from-database-query/m-p/9622#M3921</link>
    <description>&lt;P&gt;Tanks, that works great!&lt;BR /&gt;I had to modify just a tiny bit:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;return {rows: parsed};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;as otherwise it would just return an array (although in the job history UI of course it looks like an Object with an "&lt;SPAN class=""&gt;Output:&lt;/SPAN&gt; " array property) and I'm not sure how to map that to an output schema / capture it to return it in the API response.&lt;/P&gt;</description>
    <pubDate>Fri, 11 Apr 2025 17:28:40 GMT</pubDate>
    <dc:creator>andreasFe</dc:creator>
    <dc:date>2025-04-11T17:28:40Z</dc:date>
    <item>
      <title>Pass through JSON "string" from Database query</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/pass-through-json-quot-string-quot-from-database-query/m-p/9615#M3916</link>
      <description>&lt;P&gt;I'm querying a database from an API-Endpoint trigger and want to return the result as JSON.&lt;BR /&gt;So far nothing out of the ordinary, and it works for other usecases.&lt;/P&gt;&lt;P&gt;The data i do get back from the database though already contains a JSON string in one column.&amp;nbsp;&lt;BR /&gt;An (modified) example of the result (as "raw JSON" from the job-detail view) looks like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
	"rows": [
		{
			"id": 55540,
			"number": "7200",
			"quantity": "2037",
			"description": "Something 1/2",
			"history": "[{\"car_id\":\"493\", \"position\":\"left\", \"added\":\"20181101\", \"removed\":\"20240827\", \"ref_id\":\"55\"}]"
		},
		{
			"id": 4802,
			"number": "2600",
			"serial_num": "2306",
			"description": "Something 2/2",
			"history": "[{\"car_id\":\"84\", \"position\":\"left\", \"added\":\"20180930\", \"removed\":\"20230223\", \"ref_id\":\"846\"},{\"car_id\":\"84\", \"position\":\"left\", \"added\":\"20230320\", \"removed\":\"20250318\", \"ref_id\":\"84\"}]"
		},
		{
			"id": 55536,
			"number": "7100",
			"quantity": "2037",
			"description": "Desc 3",
			"history": "[{\"car_id\":\"493\", \"position\":\"right\", \"added\":\"20181101\", \"removed\":\"20240827\", \"ref_id\":\"55\"}]"
		},
		{
			"id": 55531,
			"number": "7600",
			"quantity": "2315",
			"description": "Desc 3",
			"history": "[{\"car_id\":\"493\", \"position\":\"right\", \"added\":\"20181101\", \"removed\":\"20240827\", \"ref_id\":\"49\"}]"
		}
	],
	"rows_count": 4
}&lt;/LI-CODE&gt;&lt;P&gt;When returning the result in the API I created a return schema that anticipates, that history should be a list (and I also tried object), with nested attributes of car_id, position, added, removed, ref_id.&lt;/P&gt;&lt;P&gt;The problem now is that i can not manage to make the history-column be interpreted as a list-pill to use in the return schema.&lt;BR /&gt;As the result set is thousands of rows, I can't manually iterate through them to convert the history-json "string" to a list that I could use afterwards (without creating thousands of tasks).&lt;BR /&gt;When using a schema that just uses a history-field with string type - the output is just like the example above. It contains all information, but the JSON is embedded &amp;amp; escaped instead of passed through.&lt;/P&gt;&lt;P&gt;Any idea on how to get this working as desired and simply "pass through" the JSON from the DB, without escaping it as a string?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2025 15:50:48 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/pass-through-json-quot-string-quot-from-database-query/m-p/9615#M3916</guid>
      <dc:creator>andreasFe</dc:creator>
      <dc:date>2025-04-11T15:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Pass through JSON "string" from Database query</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/pass-through-json-quot-string-quot-from-database-query/m-p/9617#M3918</link>
      <description>&lt;P&gt;I've dealt with similar situations before. You can't build a parser into the response schema that will "de-stringify" the string. You need to parse it in a separate action. There's a bunch of ways to do it, but to avoid loops/tasks I recommend dumping your output into a JS action and using JSON.parse like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;exports.main = async ({ foo }) =&amp;gt; {
  return JSON.parse("{\"hello\": \"hello\"}");
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;This outputs a parsed object.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2025 16:08:59 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/pass-through-json-quot-string-quot-from-database-query/m-p/9617#M3918</guid>
      <dc:creator>gary1</dc:creator>
      <dc:date>2025-04-11T16:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: Pass through JSON "string" from Database query</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/pass-through-json-quot-string-quot-from-database-query/m-p/9621#M3920</link>
      <description>&lt;P&gt;Here's the full JS snippet for returning the full array with history parsed:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;exports.main = async ({ rows }) =&amp;gt; {
  parsed = rows.map(item =&amp;gt; (
    {
      ...item,
      history: JSON.parse(item.history)
    }));
  return parsed;
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2025 16:45:29 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/pass-through-json-quot-string-quot-from-database-query/m-p/9621#M3920</guid>
      <dc:creator>gary1</dc:creator>
      <dc:date>2025-04-11T16:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: Pass through JSON "string" from Database query</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/pass-through-json-quot-string-quot-from-database-query/m-p/9622#M3921</link>
      <description>&lt;P&gt;Tanks, that works great!&lt;BR /&gt;I had to modify just a tiny bit:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;return {rows: parsed};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;as otherwise it would just return an array (although in the job history UI of course it looks like an Object with an "&lt;SPAN class=""&gt;Output:&lt;/SPAN&gt; " array property) and I'm not sure how to map that to an output schema / capture it to return it in the API response.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2025 17:28:40 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/pass-through-json-quot-string-quot-from-database-query/m-p/9622#M3921</guid>
      <dc:creator>andreasFe</dc:creator>
      <dc:date>2025-04-11T17:28:40Z</dc:date>
    </item>
  </channel>
</rss>

