You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Golang structs to json.Unmarshal a Grafana v10.4.1 dashboard JSON, make some changes to the dashboard, json.Marshal it and upload the new dashboard back to Grafana. I noticed that Grafana v10.4.1 keeps empty lists in the JSON as is (e.g. "links": []). However, if I do json.Unmarshal into a variable of type Dashboard and then json.Marshal, empty lists are no longer present in the JSON (for example, Dashboard.Links or Dashboard.Tags, but also applicable to any slices in other structs used in Dashboard). This is because of the omitempty in the json tags.
Why it's problematic? If I then upload the JSON to Grafana and refresh a dashboard UI, the dashboard is in a dirty state: clicking on Save dashboard button shows multiple outstanding changes, primarily to add those empty lists back to the JSON.
Are there specific reasons to have omitempty for slices and is it possible to remove them?
Thanks,
Oleh
The text was updated successfully, but these errors were encountered:
What do you need?
Hi!
I'm using Golang structs to
json.Unmarshal
a Grafana v10.4.1 dashboard JSON, make some changes to the dashboard,json.Marshal
it and upload the new dashboard back to Grafana. I noticed that Grafana v10.4.1 keeps empty lists in the JSON as is (e.g."links": []
). However, if I dojson.Unmarshal
into a variable of typeDashboard
and thenjson.Marshal
, empty lists are no longer present in the JSON (for example,Dashboard.Links
orDashboard.Tags
, but also applicable to any slices in other structs used in Dashboard). This is because of theomitempty
in the json tags.Why it's problematic? If I then upload the JSON to Grafana and refresh a dashboard UI, the dashboard is in a dirty state: clicking on
Save dashboard
button shows multiple outstanding changes, primarily to add those empty lists back to the JSON.Are there specific reasons to have
omitempty
for slices and is it possible to remove them?Thanks,
Oleh
The text was updated successfully, but these errors were encountered: