xcall
xcall copied to clipboard
Unable to handle nested JSON objects
:wave: I'm using xcall
with Bear's x-callback-url
scheme, documented here.
Mostly this is working great, but with one exception: Where Bear's x-success
contains nested JSON objects, for example the todo
action (which returns an array of objects), xcall
fails to properly JSON encode this data.
Example
# search for a todo containing 'hereismytodo'
xcall -url "bear://x-callback-url/todo?token=$BEAR_TOKEN&search=hereismytodo"
Returns the following (note how the notes
property is a JSON escaped string):
{
"notes" : "[{\"creationDate\":\"2022-01-18T21:43:37Z\",\"tags\":\"[]\",\"title\":\"- [ ] hereismytodo\",\"modificationDate\":\"2022-01-18T21:43:44Z\",\"identifier\":\"143D2519-2F4A-49C3-AA20-8A796673D036-70083-0003798CC0EB8A8E\",\"pin\":\"no\"}]",
"" : null
}
Instead, the following should be returned:
{
"notes": [
{
"creationDate": "2022-01-18T21:43:37Z",
"tags": "[]",
"title": "- [ ] hereismytodo",
"modificationDate": "2022-01-18T21:43:44Z",
"identifier": "143D2519-2F4A-49C3-AA20-8A796673D036-70083-0003798CC0EB8A8E",
"pin": "no"
}
]
}
It looks like the source of the issue is in jsonStringFromQueryItems
, where it appears to assume the object is a simple set of key/value pairs:
https://github.com/martinfinke/xcall/blob/0d61fea9c509de18be22720ded0d30c9b7ce965f/xcall/AppDelegate.m#L111-L122
I would love to PR this, but I'm not familiar with Objective-C 🤔
/cc @pr1mal -- wondering if you've seen this / can provide guidance given your work in #6 :bow: