kristopolous / TickTick

JSON in your Bash scripts
http://9ol.es/TheEmperorsNewClothes.html
Other
579 stars 55 forks source link

class with numbers doesn't work in parsing. #25

Closed 1kko closed 12 years ago

1kko commented 12 years ago

It's a great bash script. I was parsing some sort of data like this:

test.json

{
    "test_1": {
        "origin" : {
            "name" : "test2" 
        },
    "test_2": {
        "origin": {
            "name": "test2"
        }
}

now i'm importing test.json from my bash script.

DATA=`cat ./test.json`
tickParse "$DATA"

echo ``test_1[origin[name]]``

but i only get blank.

so I was looking at the issue lists, i found way to debug, using __tick_var_debug=1 after then, I'm looking following output

#!/bin/bash
__tick_var_debug=1
. ticktick.sh

DATA=`cat ./test.json`
tickParse "$DATA"

echo ${__tick_data_test_000000000001_origin_name}

Now It seems like tickParse is rewriting numbers in my classes. last line should be ${__tick_data_test_1_origin_name} not ${__tick_data_test_000000000001_origin_name}

kristopolous commented 12 years ago

I totally see the problem, it's the use of the underscores ... drats ... let me think about this one.

kristopolous commented 12 years ago

try giving this one a go. thanks.

1kko commented 10 years ago

Sorry for late reply. It fixed perfectly! Thanks!