Forum Discussion

saks-devnull_34's avatar
saks-devnull_34
Icon for Nimbostratus rankNimbostratus
May 14, 2018

Parsing string Data-Groups with Arrays as value?

Hello, I was hoping someone can share some working examples or help point me in the right direction regarding a string data-group with an array as a value.

String Data-Group:

key = record1 and value = ["name": "value", "meta": "value", "proto": "value"]
key = record2 and value = ["name": "value", "meta": "value", "proto": "value"]
key = record3…

I need to then reference the data-group in a TCL iRule to lookup what is the value of record2.meta. Similar to objectName.property in Javascript but the property is always a string.

I was attempting to use a combination of

[class match]
or
[array]
commands to access the array data, but failed to do so.

Thanks

1 Reply

  • Hi,

    You can create a list

    key = record1 and value = {"name" "value" "meta" "value" "proto" "value"}
    key = record2 and value = {"name" "value" "meta" "value" "proto" "value"}
    

    Then, in the irule, convert the list to array

    array set myarray [class match -value $key equals "mykey"]