I'm new to JSON construction and I can't quite wrap my brain round how I do this. I can't even think of the vocabulary to ask Google...
I want to create JSON that looks like this:
[{
"common": {
"attributes": {
"logtype": "accesslogs",
"service": "login-service",
"hostname": "login.example.com"
}
},
"logs": [{
"message": "User 'xyz' logged in"
},{
"message": "User 'xyz' logged out",
"attributes": {
"auditId": 123
}
}]
}]
Note the whole lot is in a single array element, inside a single hashtable element containing "common" and "logs". Common contains a single hashtable "attributes" element with hashtable key pairs. Logs contains a sub array, consisting of a single array element, with hashtable inside. The hashtable can have an optional attributes sub hashtable with key pairs.
Common appears once, logs array elements can repeat.
I hope that makes sense. Help greatly appreciated.
Thanks.
I've tried lots, and I can't get close.