Problem with parsing JSON content from URL

211 views
Skip to first unread message

François

unread,
Apr 14, 2012, 5:35:57 AM4/14/12
to TickTick
Hi,

I am just trying TickTick and it works good except when I retrieve
JSON from an URL. This is my code:
---
. /usr/lib/TickTick/ticktick.sh

kernel=`wget -qO- http://co2.16mb.com/kernel/`

tickParse "$kernel"

echo 'kernel:'$(printf %d ``kernel.revision``)
---

And this is the output from the URL:
{"revision":10}

And this the output the script produce in terminal:
kernel:0

What am I doing wrong?

Thank you

Christopher McKenzie

unread,
May 7, 2012, 8:36:17 PM5/7/12
to ticktick...@googlegroups.com
just saw this ... I'll get back to you tonight.

Chris McKenzie

unread,
Aug 22, 2012, 8:44:27 PM8/22/12
to ticktick...@googlegroups.com
Tonight as in a couple months later ... Anyway, your bug is that it is top level

That is to say that 

. /usr/lib/TickTick/ticktick.sh 

kernel=`wget -qO- http://co2.16mb.com/kernel/` 

tickParse "$kernel" 

echo 'kernel:'$(printf %d ``revision``) 

is what you need.  tickParse "$kernel" won't take the contents of kernel, then reflectively assign them back to a superstructure of kernel. Alas, no, it just  takes the contents of the variable and then evals it, thus assigning it to the global space.

I was able to debug this by doing this:

...
tickParse "$kernel" 

set

echo 'kernel:'$(printf %d ``revision``) 
...

The output of set gave me the insight here ... I didn't know it immediately either.  How tricky. Hope this helps!!
Reply all
Reply to author
Forward
0 new messages