Convert string into json in AQL queries

222 views
Skip to first unread message

Subhrajyoti Moitra

unread,
Sep 15, 2016, 8:13:26 AM9/15/16
to ArangoDB
Hello,
I have json documents being saved in the ArangoDB, which itself contains json document as a string value.

{
  "requestBody": "[{\"suborderNo\":41357335034,\"taskType\":\"SALES_RETURN_DFC\",\"userId\":\"1010835_1673\",\"taskId\":\"BPMN_MarkSalesReturnQC\",\"taskVariables\":{\"instructionsToAccount\":\"DBTV\",\"reason\":\"RIGC\",\"disputeRejected\":true,\"disputeRaised\":false,\"disputeTaskCompletedBy\":\"TopNotch_HS18\"}}]",
  "timestamp": "2016-09-15T15:18:43.587+0530",
  "url": "/CaseManagementSystem/api/bulkupload/completebulktask/"
}

Notice the "requestBody" attribute. Its an arrays JSON string.
I want the object version of this attribute to be returned.

for i in TASK_INTERCEPT_EVENTS
filter i.url=="/CaseManagementSystem/api/bulkupload/completebulktask/"
let ix=i.requestBody
return JSON.parse(ix)

Something in this lines... But the above is failing. Please advice

Thanks,
Subhro.



Jan

unread,
Sep 27, 2016, 5:03:24 AM9/27/16
to ArangoDB
For info: the upcoming ArangoDB version 3.1 will likely provide the AQL functions JSON_PARSE() and JSON_STRINGIFY().
For 3.0 and 2.8 the workaround is to use a custom AQL function that just wraps the JSON.parse() JavaScript command.

Best regards
Jan
Reply all
Reply to author
Forward
0 new messages