To solve my immediate problem, I have devised a method that works, at least in
the very limited test cases I have run.
I would still like something better if it exists, or any methods using TickTick
internals, because I suspect this thing will crumble in a stiff breeze. I also
suspect it's slower than this task should be.
I thought I would post it here for anyone looking through the archives.
#Takes the array we want to split into, and the key we want split
function kSplitter {
arrayName="$1"
shift
local IFS='_'
for word in ${1:12}; do
eval $arrayName=\(\""$word"\"\)
done
}
# Test case for my "test" object (below)
for item in ``test.items()``; do
declare -a keys
kSplitter keys "$item"
# Print the most RHS key, and the value
echo "${keys[-1]}: ${!item}"
done
Luke
3.5 hours ago, I wrote:
> I need to retrieve not only values for an object/array, but also the keys.
> How might I go about this?
>
> For example:
>
> ``
> test = {
> "sequence": 12,
> "method": "destructive",
> "targets": [
> "red",
> "blue"
> ]
> }
> ``
>
> What if I wanted to know the keys for test, because, for example, it just
> came back through curl and I didn't have them ahead of time?
[.]