Could anyone help me parse the following JSON? The tags do not contain "["/"]" brackets, but the left-hand variable names there are indefinite:
Example 1:
{
"value": 569000000,
"tags": {
"importerId": "catchacar",
"jvmProcess": "12367A"
}
}
Example 2:
{
"value": 519,
"tags": {
"cluster": "cluster-29042",
"valueName": "open-files"
},
"time": "2017-09-05T11:03:57.877Z"
}
etc
How can I define a struct which catches arbitrary left-hand values ? I have found the following:
type JSONTag struct {
ValueName string `json:"valueName"` <--- what to write here ????
Value string `json:"value"`
}
type JSONMessage struct {
Value float64 `json:"value"`
Time string `json:"time"`
Tags []JSONTag `json:"tags"`
}
group := JSONMessage{
Value: 123,
Time: "2017-09-01T14:26:33.773Z",
Tags: []JSONTag{JSONTag{"valName1", "val1"}},
}
But this produces and needs brackets. Example:
{
"value": 123,
"time": "2017-09-01T14:26:33.773Z",
"tags": [
{
"valueName": "valName1",
"value": "val1"
}
]
}
Thank you very much !