Hello all,

 

I have redis database where the data is inserted in JSON format:

 

#Redis Command

 

JSON.GET Index1J:12345678

 

#Redis Result

[

  {

    "SupplierID": "7",

    "BCode": "987654",

    "Rate": 0.159

  },

  {

    "SupplierID": "7",

    "BCode": "765432",

    "Rate": 0.159

  },

  {

    "SupplierID": "7",

    "BCode": "5432159",

    "Rate": 0.159

  }

]

 

When I try to get the result using Lua script in Kamailio like the following:

#kamailio command

  if KSR.ndb_redis.redis_cmd("srvN", "JSON.GET pricelistJ:441246890", "ra") then

            KSR.xlog.xinfo("array size: $redis(ra=>size)\n");

            KSR.xlog.xinfo("Redis Response: " .. tostring(ra) .. "\n")

            KSR.xlog.xinfo("first values: $redis(ra=>value[0]) , $redis(ra=>value[1])\n");

        end

                               

Nov 7 07:58:15 868d08ee318d /usr/sbin/kamailio[72]: INFO: LUA {INVITE}: <script>: array size: <null>

Nov  7 07:58:15 868d08ee318d /usr/sbin/kamailio[72]: INFO: LUA {INVITE}: <script>: Redis Response: nil

Nov  7 07:58:15 868d08ee318d /usr/sbin/kamailio[72]: INFO: LUA {INVITE}: <script>: first values: <null> , <null>

 

I’m getting null results.

 

I don’t know what I’m doing wrong here. Can you please assist?