kristopolous / TickTick

JSON in your Bash scripts

Home Page:http://9ol.es/TheEmperorsNewClothes.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

class with numbers doesn't work in parsing.

1kko opened this issue · comments

commented

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}

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

try giving this one a go. thanks.

commented

Sorry for late reply. It fixed perfectly! Thanks!