[ZBXNEXT-1623] Generic JSON validation support Created: 2013 Feb 14  Updated: 2024 Sep 10

Status: Open
Project: ZABBIX FEATURE REQUESTS
Component/s: Agent (G), Proxy (P), Server (S)
Affects Version/s: None
Fix Version/s: None

Type: Change Request Priority: Trivial
Reporter: Andris Zeila Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: json, validation
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Currently the validation of received JSON data is done locally in various components. The validation level depends on the component - for example in some places the field format (type) is checked while in other places it is not.

One way would be to use JSON schemas for validation. However that might be too 'heavy' approach and it would be better to create some generic lightweight validation funcitonality.



 Comments   
Comment by richlv [ 2013 Oct 15 ]

(1) not strictly json validation, but general validation issue - how zabbix sender data is validated.
a) header is optional - skipping it works just fine.
b) looks like sender itself is not sending the header.
c) if header is included, length is ignored unless it's 0 - then sending silently fails.

Comment by Mickael Martin [ 2023 Mar 27 ]

hello, we use this code in item validation :

try {
JSON.parse(value);
    } catch (e) {
        return e;
    }
    return value;
}

with a trigger find(itemkey,#1,"like","SyntaxError") = 1

or just

return JSON.parse(value);

with a nodata trigger.
But a "predefined" validation of json can be a best approch.

Generated at Fri Mar 14 17:13:26 EET 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.