Some courses and learning paths on NI Learning Center may not appear on learner dashboards. Our team is actively investigating.

If you encounter access issues, please contact services@ni.com and include the learner’s name, email, service ID or EA number, and the list of required courses.

JDP Science Tools

cancel
Showing results for 
Search instead for 
Did you mean: 

JSONtext: JSON Schema?

It's been suggested that I think about adding a basic JSON validation schema capability to JSONtext.  What do people think?  

 

An example:

{
  "type": "object",
  "properties": {
    "number": { "type": "number" },
    "street_name": { "type": "string" },
    "street_type": { "enum": ["Street", "Avenue", "Boulevard"] }
  }
}
Message 1 of 29
(7,153 Views)

Would you interpret the schema during parsing, on demand, or just include it for the developer's benefit?

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 2 of 29
(7,133 Views)

@Thoric wrote:

Would you interpret the schema during parsing, on demand, or just include it for the developer's benefit?


There would be a new "Validate JSON Schema" VI, that would have inputs for both a JSON Schema, and a JSON Value to validate (ie. it is used on demand).  Would return "Valid" T/F, and hopefully reason for it not being valid.

 

A JSON Schema can specify things like "must include certain items", or "'Temperature' must be a number", or "'Position' must be an array of three numbers". 

Message 3 of 29
(7,127 Views)

Could also have a "Generate JSON Schema from LV Datatype" subVI, that would generate the Schema from an input type (including things like cluster names and types, and enum values).  This could be used be a programmer in a different language to validate that their JSON is in the right form to be understood in LabVIEW.

Message 4 of 29
(7,123 Views)

I have to say, these sound clever and potentially useful. Although I don't have a user case today it's not impossible in the future.

 

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 5 of 29
(7,105 Views)

I love JSON Schema and would love this feature to more easily validate configuration files.

0 Kudos
Message 6 of 29
(6,776 Views)

This would be a great feature. Any plans to actually add this in the near future to the toolkit?

0 Kudos
Message 7 of 29
(6,464 Views)

I'd like this very much as well

0 Kudos
Message 8 of 29
(6,208 Views)

Here is a beta version with JSON Schema.  See the example "JSON Schema Validation".

Message 9 of 29
(5,922 Views)

Thanks James for adding this.

 

It would be nice if the "Failure Reason" would also contain the label of the element that failed.

 

Best Regards,

Stefan

0 Kudos
Message 10 of 29
(5,891 Views)