Parse an array as list

Parse an array as list
0

Hello everyone :)

I'm writing my first IND script, I want to parase the following JSON array:

"allow":["192.168.135.1","172.28.65.150","172.28.31.140","10.0.0.0/24","All"]

And print it as a live config.

I couldn't find a way to prase the array into a list (without key values)


Code:

Image title


Output:


INFO - Metric Name: allowed-ips ||| Tags: device = F5 ||| Value: [ {
"IP" : "10.0.0.0/24"
}, {
"IP" : "172.28.31.140"
}, {
"IP" : "172.28.65.150"
}, {
"IP" : "192.168.135.1"
}, {
"IP" : "All"
} ]


Source:

https://bitbucket.org/indeni/indeni-knowledge/branch/IKP-692-f5-management-ip-accessible-from#chg-parsers/src/f5/sys/rest-mgmt-tm-sys-httpd-allowed.ind


Any suggestions?


Thanks,

Daniel.

Can you please create a test case with inout and expected output so we will be able to help?

Hey there Daniel,


Our data structure for the complex / snapshot metrics is quite restrictive, and is in fact a simplified JSON.


It only comes in two forms:

  1. A key-value map, where the value may only be a primitive value (but not arrays nor nested objects).
  2. An array of #1.

So basically your attempt to list the IPs was actually the correct way to do it.


Glad to have you on board with us :)